Skip to content
Browse files

minor #9487 unify constructor initialization style throughout symfony…

… (Tobion)

This PR was merged into the master branch.

Discussion
----------

unify constructor initialization style throughout symfony

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | n/a

In almost all classes symfony uses property initialization when the value is static. Constructor initialization is only used for things that actually have logic, like passed parameters or dynamic values. IMHO it makes the code much more readable because property definition, phpdoc and default value is in one place. Also one can easily see what the constructor implements for logic like overridden default value of a parent class. Otherwise the real deal is just hidden behind 10 property initializations. One more advantage is that it requires less code. As you can see, the code was almost cut in half (210 additions and 395 deletions).
I unified it accordingly across symfony. Sometimes it was [not even consistent within one class](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Config/Definition/BaseNode.php#L32). At the same time I recognized some errors like missing parent constructor call, or undefined properties or private properties that are not even used.

I then realized that a few Kernel tests were not passing because they were deeply implementation specific like modifying booted flag with a custom `KernelForTest->setIsBooted();`. I improved and refactored the kernel tests in the __second commit__.

__Third commit__ unifies short ternary operator, e.g. `$foo ?: new Foo()`. __Forth commit__ unifies missing parentheses, e.g. `new Foo()`.

Commits
-------

077a089 unify missing parentheses
2888594 unify short ternary operator
2a9daff [HttpKernel] better written kernel tests
111ac18 unify constructor initialization style throughout symfony
  • Loading branch information...
2 parents efff757 + 077a089 commit b74a887cd93d5ba864015e899cca790999262f65 @fabpot fabpot committed
Showing with 395 additions and 658 deletions.
  1. +2 −3 src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
  2. +2 −4 src/Symfony/Bridge/Twig/NodeVisitor/Scope.php
  3. +1 −1 src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
  4. +1 −2 src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php
  5. +4 −6 src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
  6. +0 −2 src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
  7. +1 −2 src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php
  8. +8 −13 src/Symfony/Component/BrowserKit/Client.php
  9. +0 −8 src/Symfony/Component/BrowserKit/History.php
  10. +8 −28 src/Symfony/Component/Config/Definition/ArrayNode.php
  11. +5 −10 src/Symfony/Component/Config/Definition/BaseNode.php
  12. +8 −16 src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
  13. +2 −4 src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php
  14. +10 −13 src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
  15. +2 −5 src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php
  16. +1 −3 src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php
  17. +1 −4 src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php
  18. +3 −17 src/Symfony/Component/Config/Definition/PrototypedArrayNode.php
  19. +1 −2 src/Symfony/Component/Config/Loader/LoaderResolver.php
  20. +1 −2 src/Symfony/Component/Console/Helper/HelperSet.php
  21. +5 −4 src/Symfony/Component/Console/Input/Input.php
  22. +1 −1 src/Symfony/Component/Console/Output/Output.php
  23. +1 −2 src/Symfony/Component/Console/Shell.php
  24. +1 −1 src/Symfony/Component/Console/Tests/ApplicationTest.php
  25. +1 −2 src/Symfony/Component/CssSelector/Parser/Reader.php
  26. +1 −2 src/Symfony/Component/DependencyInjection/Compiler/Compiler.php
  27. +3 −7 src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
  28. +1 −9 src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php
  29. +2 −4 src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php
  30. +8 −15 src/Symfony/Component/DependencyInjection/Container.php
  31. +17 −26 src/Symfony/Component/DependencyInjection/Definition.php
  32. +1 −2 src/Symfony/Component/DependencyInjection/DefinitionDecorator.php
  33. +2 −4 src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
  34. +1 −1 src/Symfony/Component/EventDispatcher/Tests/EventTest.php
  35. +1 −2 src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php
  36. +7 −5 src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php
  37. +3 −1 src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php
  38. +4 −1 src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php
  39. +4 −2 src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php
  40. +4 −2 src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php
  41. +4 −1 src/Symfony/Component/ExpressionLanguage/Node/NameNode.php
  42. +4 −2 src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php
  43. +1 −2 src/Symfony/Component/ExpressionLanguage/TokenStream.php
  44. +1 −2 src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php
  45. +2 −4 src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php
  46. +2 −4 src/Symfony/Component/Finder/Shell/Command.php
  47. +1 −2 src/Symfony/Component/Finder/Tests/Iterator/Iterator.php
  48. +3 −3 src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php
  49. +2 −4 src/Symfony/Component/HttpFoundation/HeaderBag.php
  50. +1 −2 src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php
  51. +1 −2 src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php
  52. +1 −1 src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php
  53. +4 −4 src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
  54. +1 −1 src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
  55. +1 −1 src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php
  56. +1 −1 src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php
  57. +5 −4 src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php
  58. +1 −2 src/Symfony/Component/HttpKernel/Client.php
  59. +3 −6 src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php
  60. +1 −2 src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php
  61. +1 −2 src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php
  62. +3 −3 src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
  63. +2 −4 src/Symfony/Component/HttpKernel/Kernel.php
  64. +1 −1 src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php
  65. +1 −1 src/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php
  66. +2 −2 src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php
  67. +1 −18 src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php
  68. +2 −4 src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php
  69. +4 −10 src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php
  70. +101 −164 src/Symfony/Component/HttpKernel/Tests/KernelTest.php
  71. +2 −8 src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php
  72. +2 −8 src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php
  73. +2 −9 src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php
  74. +4 −9 src/Symfony/Component/Process/ProcessBuilder.php
  75. +5 −11 src/Symfony/Component/Routing/Annotation/Route.php
  76. +1 −1 src/Symfony/Component/Routing/Router.php
  77. +2 −2 src/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php
  78. +2 −4 src/Symfony/Component/Security/Acl/Dbal/AclProvider.php
  79. +5 −11 src/Symfony/Component/Security/Acl/Domain/Acl.php
  80. +1 −1 src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php
  81. +3 −7 src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php
  82. +1 −2 src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php
  83. +11 −11 src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php
  84. +12 −12 src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php
  85. +8 −8 src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php
  86. +2 −2 src/Symfony/Component/Serializer/Encoder/JsonEncoder.php
  87. +1 −1 src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php
  88. +8 −8 src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php
  89. +6 −6 src/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php
  90. +3 −3 src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
  91. +3 −3 src/Symfony/Component/Serializer/Tests/SerializerTest.php
  92. +6 −8 src/Symfony/Component/Stopwatch/StopwatchEvent.php
  93. +3 −3 src/Symfony/Component/Stopwatch/StopwatchPeriod.php
  94. +1 −2 src/Symfony/Component/Templating/DelegatingEngine.php
  95. +1 −2 src/Symfony/Component/Templating/Helper/CoreAssetsHelper.php
  96. +1 −2 src/Symfony/Component/Templating/Loader/ChainLoader.php
  97. +9 −14 src/Symfony/Component/Templating/PhpEngine.php
  98. +1 −1 src/Symfony/Component/Validator/Constraints/Collection.php
  99. +2 −2 src/Symfony/Component/Validator/Tests/ConstraintTest.php
View
5 src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
@@ -24,12 +24,11 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
{
protected $registry;
- private $cache;
+ private $cache = array();
public function __construct(ManagerRegistry $registry)
{
$this->registry = $registry;
- $this->cache = array();
}
/**
@@ -90,7 +89,7 @@ public function guessRequired($class, $property)
return null;
}
- /* @var ClassMetadataInfo $classMetadata */
+ /** @var ClassMetadataInfo $classMetadata */
$classMetadata = $classMetadatas[0];
// Check whether the field exists and is nullable or not
View
6 src/Symfony/Bridge/Twig/NodeVisitor/Scope.php
@@ -29,12 +29,12 @@ class Scope
/**
* @var array
*/
- private $data;
+ private $data = array();
/**
* @var boolean
*/
- private $left;
+ private $left = false;
/**
* @param Scope $parent
@@ -42,8 +42,6 @@ class Scope
public function __construct(Scope $parent = null)
{
$this->parent = $parent;
- $this->left = false;
- $this->data = array();
}
/**
View
2 src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
@@ -41,7 +41,7 @@ public function __construct(ContainerInterface $container, $resource, array $opt
$this->container = $container;
$this->resource = $resource;
- $this->context = null === $context ? new RequestContext() : $context;
+ $this->context = $context ?: new RequestContext();
$this->setOptions($options);
}
View
3 src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php
@@ -25,7 +25,7 @@
class TemplateNameParser implements TemplateNameParserInterface
{
protected $kernel;
- protected $cache;
+ protected $cache = array();
/**
* Constructor.
@@ -35,7 +35,6 @@ class TemplateNameParser implements TemplateNameParserInterface
public function __construct(KernelInterface $kernel)
{
$this->kernel = $kernel;
- $this->cache = array();
}
/**
View
10 src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
@@ -24,7 +24,10 @@
class Translator extends BaseTranslator
{
protected $container;
- protected $options;
+ protected $options = array(
+ 'cache_dir' => null,
+ 'debug' => false,
+ );
protected $loaderIds;
/**
@@ -47,11 +50,6 @@ public function __construct(ContainerInterface $container, MessageSelector $sele
$this->container = $container;
$this->loaderIds = $loaderIds;
- $this->options = array(
- 'cache_dir' => null,
- 'debug' => false,
- );
-
// check option names
if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
throw new \InvalidArgumentException(sprintf('The Translator does not support the following options: \'%s\'.', implode('\', \'', $diff)));
View
2 src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
@@ -14,7 +14,6 @@
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
-use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
@@ -23,7 +22,6 @@
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\Config\FileLocator;
-use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\Security\Core\Authorization\ExpressionLanguage;
/**
View
3 src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php
@@ -26,7 +26,7 @@
class LogoutUrlHelper extends Helper
{
private $container;
- private $listeners;
+ private $listeners = array();
private $router;
/**
@@ -39,7 +39,6 @@ public function __construct(ContainerInterface $container, UrlGeneratorInterface
{
$this->container = $container;
$this->router = $router;
- $this->listeners = array();
}
/**
View
21 src/Symfony/Component/BrowserKit/Client.php
@@ -32,19 +32,19 @@
{
protected $history;
protected $cookieJar;
- protected $server;
+ protected $server = array();
protected $internalRequest;
protected $request;
protected $internalResponse;
protected $response;
protected $crawler;
- protected $insulated;
+ protected $insulated = false;
protected $redirect;
- protected $followRedirects;
+ protected $followRedirects = true;
- private $maxRedirects;
- private $redirectCount;
- private $isMainRequest;
+ private $maxRedirects = -1;
+ private $redirectCount = 0;
+ private $isMainRequest = true;
/**
* Constructor.
@@ -58,13 +58,8 @@
public function __construct(array $server = array(), History $history = null, CookieJar $cookieJar = null)
{
$this->setServerParameters($server);
- $this->history = null === $history ? new History() : $history;
- $this->cookieJar = null === $cookieJar ? new CookieJar() : $cookieJar;
- $this->insulated = false;
- $this->followRedirects = true;
- $this->maxRedirects = -1;
- $this->redirectCount = 0;
- $this->isMainRequest = true;
+ $this->history = $history ?: new History();
+ $this->cookieJar = $cookieJar ?: new CookieJar();
}
/**
View
8 src/Symfony/Component/BrowserKit/History.php
@@ -22,14 +22,6 @@ class History
protected $position = -1;
/**
- * Constructor.
- */
- public function __construct()
- {
- $this->clear();
- }
-
- /**
* Clears the history.
*/
public function clear()
View
36 src/Symfony/Component/Config/Definition/ArrayNode.php
@@ -22,34 +22,14 @@
*/
class ArrayNode extends BaseNode implements PrototypeNodeInterface
{
- protected $xmlRemappings;
- protected $children;
- protected $allowFalse;
- protected $allowNewKeys;
- protected $addIfNotSet;
- protected $performDeepMerging;
- protected $ignoreExtraKeys;
- protected $normalizeKeys;
-
- /**
- * Constructor.
- *
- * @param string $name The Node's name
- * @param NodeInterface $parent The node parent
- */
- public function __construct($name, NodeInterface $parent = null)
- {
- parent::__construct($name, $parent);
-
- $this->children = array();
- $this->xmlRemappings = array();
- $this->removeKeyAttribute = true;
- $this->allowFalse = false;
- $this->addIfNotSet = false;
- $this->allowNewKeys = true;
- $this->performDeepMerging = true;
- $this->normalizeKeys = true;
- }
+ protected $xmlRemappings = array();
+ protected $children = array();
+ protected $allowFalse = false;
+ protected $allowNewKeys = true;
+ protected $addIfNotSet = false;
+ protected $performDeepMerging = true;
+ protected $ignoreExtraKeys = false;
+ protected $normalizeKeys = true;
public function setNormalizeKeys($normalizeKeys)
{
View
15 src/Symfony/Component/Config/Definition/BaseNode.php
@@ -24,11 +24,11 @@
{
protected $name;
protected $parent;
- protected $normalizationClosures;
- protected $finalValidationClosures;
- protected $allowOverwrite;
- protected $required;
- protected $equivalentValues;
+ protected $normalizationClosures = array();
+ protected $finalValidationClosures = array();
+ protected $allowOverwrite = true;
+ protected $required = false;
+ protected $equivalentValues = array();
protected $attributes = array();
/**
@@ -47,11 +47,6 @@ public function __construct($name, NodeInterface $parent = null)
$this->name = $name;
$this->parent = $parent;
- $this->normalizationClosures = array();
- $this->finalValidationClosures = array();
- $this->allowOverwrite = true;
- $this->required = false;
- $this->equivalentValues = array();
}
public function setAttribute($key, $value)
View
24 src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
@@ -22,18 +22,18 @@
*/
class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinitionInterface
{
- protected $performDeepMerging;
- protected $ignoreExtraKeys;
- protected $children;
+ protected $performDeepMerging = true;
+ protected $ignoreExtraKeys = false;
+ protected $children = array();
protected $prototype;
- protected $atLeastOne;
- protected $allowNewKeys;
+ protected $atLeastOne = false;
+ protected $allowNewKeys = true;
protected $key;
protected $removeKeyItem;
- protected $addDefaults;
- protected $addDefaultChildren;
+ protected $addDefaults = false;
+ protected $addDefaultChildren = false;
protected $nodeBuilder;
- protected $normalizeKeys;
+ protected $normalizeKeys = true;
/**
* {@inheritDoc}
@@ -42,16 +42,8 @@ public function __construct($name, NodeParentInterface $parent = null)
{
parent::__construct($name, $parent);
- $this->children = array();
- $this->addDefaults = false;
- $this->addDefaultChildren = false;
- $this->allowNewKeys = true;
- $this->atLeastOne = false;
- $this->allowEmptyValue = true;
- $this->performDeepMerging = true;
$this->nullEquivalent = array();
$this->trueEquivalent = array();
- $this->normalizeKeys = true;
}
/**
View
6 src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php
@@ -19,8 +19,8 @@
class MergeBuilder
{
protected $node;
- public $allowFalse;
- public $allowOverwrite;
+ public $allowFalse = false;
+ public $allowOverwrite = true;
/**
* Constructor
@@ -30,8 +30,6 @@ class MergeBuilder
public function __construct(NodeDefinition $node)
{
$this->node = $node;
- $this->allowFalse = false;
- $this->allowOverwrite = true;
}
/**
View
23 src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
@@ -25,15 +25,16 @@
protected $normalization;
protected $validation;
protected $defaultValue;
- protected $default;
- protected $required;
+ protected $default = false;
+ protected $required = false;
protected $merge;
- protected $allowEmptyValue;
+ protected $allowEmptyValue = true;
protected $nullEquivalent;
- protected $trueEquivalent;
- protected $falseEquivalent;
+ protected $trueEquivalent = true;
+ protected $falseEquivalent = false;
+
/**
- * @var NodeParentInterface|NodeInterface
+ * @var NodeParentInterface|null
*/
protected $parent;
protected $attributes = array();
@@ -41,17 +42,13 @@
/**
* Constructor
*
- * @param string $name The name of the node
- * @param NodeParentInterface $parent The parent
+ * @param string $name The name of the node
+ * @param NodeParentInterface|null $parent The parent
*/
public function __construct($name, NodeParentInterface $parent = null)
{
$this->parent = $parent;
$this->name = $name;
- $this->default = false;
- $this->required = false;
- $this->trueEquivalent = true;
- $this->falseEquivalent = false;
}
/**
@@ -110,7 +107,7 @@ public function attribute($key, $value)
/**
* Returns the parent node.
*
- * @return NodeParentInterface The builder of the parent node
+ * @return NodeParentInterface|null The builder of the parent node
*/
public function end()
{
View
7 src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php
@@ -19,8 +19,8 @@
class NormalizationBuilder
{
protected $node;
- public $before;
- public $remappings;
+ public $before = array();
+ public $remappings = array();
/**
* Constructor
@@ -30,9 +30,6 @@ class NormalizationBuilder
public function __construct(NodeDefinition $node)
{
$this->node = $node;
- $this->keys = false;
- $this->remappings = array();
- $this->before = array();
}
/**
View
4 src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php
@@ -19,7 +19,7 @@
class ValidationBuilder
{
protected $node;
- public $rules;
+ public $rules = array();
/**
* Constructor
@@ -29,8 +29,6 @@ class ValidationBuilder
public function __construct(NodeDefinition $node)
{
$this->node = $node;
-
- $this->rules = array();
}
/**
View
5 src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php
@@ -49,10 +49,7 @@ protected function createNode()
$node->setDefaultValue($this->defaultValue);
}
- if (false === $this->allowEmptyValue) {
- $node->setAllowEmptyValue($this->allowEmptyValue);
- }
-
+ $node->setAllowEmptyValue($this->allowEmptyValue);
$node->addEquivalentValue(null, $this->nullEquivalent);
$node->addEquivalentValue(true, $this->trueEquivalent);
$node->addEquivalentValue(false, $this->falseEquivalent);
View
20 src/Symfony/Component/Config/Definition/PrototypedArrayNode.php
@@ -25,26 +25,12 @@ class PrototypedArrayNode extends ArrayNode
{
protected $prototype;
protected $keyAttribute;
- protected $removeKeyAttribute;
- protected $minNumberOfElements;
- protected $defaultValue;
+ protected $removeKeyAttribute = false;
+ protected $minNumberOfElements = 0;
+ protected $defaultValue = array();
protected $defaultChildren;
/**
- * Constructor.
- *
- * @param string $name The Node's name
- * @param NodeInterface $parent The node parent
- */
- public function __construct($name, NodeInterface $parent = null)
- {
- parent::__construct($name, $parent);
-
- $this->minNumberOfElements = 0;
- $this->defaultValue = array();
- }
-
- /**
* Sets the minimum number of elements that a prototype based node must
* contain. By default this is zero, meaning no elements.
*
View
3 src/Symfony/Component/Config/Loader/LoaderResolver.php
@@ -24,7 +24,7 @@ class LoaderResolver implements LoaderResolverInterface
/**
* @var LoaderInterface[] An array of LoaderInterface objects
*/
- private $loaders;
+ private $loaders = array();
/**
* Constructor.
@@ -33,7 +33,6 @@ class LoaderResolver implements LoaderResolverInterface
*/
public function __construct(array $loaders = array())
{
- $this->loaders = array();
foreach ($loaders as $loader) {
$this->addLoader($loader);
}
View
3 src/Symfony/Component/Console/Helper/HelperSet.php
@@ -20,7 +20,7 @@
*/
class HelperSet implements \IteratorAggregate
{
- private $helpers;
+ private $helpers = array();
private $command;
/**
@@ -30,7 +30,6 @@ class HelperSet implements \IteratorAggregate
*/
public function __construct(array $helpers = array())
{
- $this->helpers = array();
foreach ($helpers as $alias => $helper) {
$this->set($helper, is_int($alias) ? null : $alias);
}
View
9 src/Symfony/Component/Console/Input/Input.php
@@ -24,9 +24,12 @@
*/
abstract class Input implements InputInterface
{
+ /**
+ * @var InputDefinition
+ */
protected $definition;
- protected $options;
- protected $arguments;
+ protected $options = array();
+ protected $arguments = array();
protected $interactive = true;
/**
@@ -37,8 +40,6 @@
public function __construct(InputDefinition $definition = null)
{
if (null === $definition) {
- $this->arguments = array();
- $this->options = array();
$this->definition = new InputDefinition();
} else {
$this->bind($definition);
View
2 src/Symfony/Component/Console/Output/Output.php
@@ -46,7 +46,7 @@
public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
{
$this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
- $this->formatter = null === $formatter ? new OutputFormatter() : $formatter;
+ $this->formatter = $formatter ?: new OutputFormatter();
$this->formatter->setDecorated($decorated);
}
View
3 src/Symfony/Component/Console/Shell.php
@@ -32,7 +32,7 @@ class Shell
private $history;
private $output;
private $hasReadline;
- private $processIsolation;
+ private $processIsolation = false;
/**
* Constructor.
@@ -48,7 +48,6 @@ public function __construct(Application $application)
$this->application = $application;
$this->history = getenv('HOME').'/.history_'.$application->getName();
$this->output = new ConsoleOutput();
- $this->processIsolation = false;
}
/**
View
2 src/Symfony/Component/Console/Tests/ApplicationTest.php
@@ -862,7 +862,7 @@ public function testTerminalDimensions()
protected function getDispatcher()
{
- $dispatcher = new EventDispatcher;
+ $dispatcher = new EventDispatcher();
$dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) {
$event->getOutput()->write('before.');
});
View
3 src/Symfony/Component/CssSelector/Parser/Reader.php
@@ -34,7 +34,7 @@ class Reader
/**
* @var int
*/
- private $position;
+ private $position = 0;
/**
* @param string $source
@@ -43,7 +43,6 @@ public function __construct($source)
{
$this->source = $source;
$this->length = strlen($source);
- $this->position = 0;
}
/**
View
3 src/Symfony/Component/DependencyInjection/Compiler/Compiler.php
@@ -24,7 +24,7 @@
class Compiler
{
private $passConfig;
- private $log;
+ private $log = array();
private $loggingFormatter;
private $serviceReferenceGraph;
@@ -36,7 +36,6 @@ public function __construct()
$this->passConfig = new PassConfig();
$this->serviceReferenceGraph = new ServiceReferenceGraph();
$this->loggingFormatter = new LoggingFormatter();
- $this->log = array();
}
/**
View
10 src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
@@ -31,9 +31,9 @@ class PassConfig
const TYPE_REMOVE = 'removing';
private $mergePass;
- private $afterRemovingPasses;
- private $beforeOptimizationPasses;
- private $beforeRemovingPasses;
+ private $afterRemovingPasses = array();
+ private $beforeOptimizationPasses = array();
+ private $beforeRemovingPasses = array();
private $optimizationPasses;
private $removingPasses;
@@ -44,10 +44,6 @@ public function __construct()
{
$this->mergePass = new MergeExtensionConfigurationPass();
- $this->afterRemovingPasses = array();
- $this->beforeOptimizationPasses = array();
- $this->beforeRemovingPasses = array();
-
$this->optimizationPasses = array(
new ResolveDefinitionTemplatesPass(),
new ResolveParameterPlaceHoldersPass(),
View
10 src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php
@@ -26,15 +26,7 @@ class ServiceReferenceGraph
/**
* @var ServiceReferenceGraphNode[]
*/
- private $nodes;
-
- /**
- * Constructor.
- */
- public function __construct()
- {
- $this->nodes = array();
- }
+ private $nodes = array();
/**
* Checks if the graph has a specific node.
View
6 src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php
@@ -24,8 +24,8 @@
class ServiceReferenceGraphNode
{
private $id;
- private $inEdges;
- private $outEdges;
+ private $inEdges = array();
+ private $outEdges = array();
private $value;
/**
@@ -38,8 +38,6 @@ public function __construct($id, $value)
{
$this->id = $id;
$this->value = $value;
- $this->inEdges = array();
- $this->outEdges = array();
}
/**
View
23 src/Symfony/Component/DependencyInjection/Container.php
@@ -67,13 +67,13 @@ class Container implements IntrospectableContainerInterface
*/
protected $parameterBag;
- protected $services;
- protected $methodMap;
- protected $aliases;
- protected $scopes;
- protected $scopeChildren;
- protected $scopedServices;
- protected $scopeStacks;
+ protected $services = array();
+ protected $methodMap = array();
+ protected $aliases = array();
+ protected $scopes = array();
+ protected $scopeChildren = array();
+ protected $scopedServices = array();
+ protected $scopeStacks = array();
protected $loading = array();
/**
@@ -85,14 +85,7 @@ class Container implements IntrospectableContainerInterface
*/
public function __construct(ParameterBagInterface $parameterBag = null)
{
- $this->parameterBag = null === $parameterBag ? new ParameterBag() : $parameterBag;
-
- $this->services = array();
- $this->aliases = array();
- $this->scopes = array();
- $this->scopeChildren = array();
- $this->scopedServices = array();
- $this->scopeStacks = array();
+ $this->parameterBag = $parameterBag ?: new ParameterBag();
$this->set('service_container', $this);
}
View
43 src/Symfony/Component/DependencyInjection/Definition.php
@@ -28,24 +28,24 @@ class Definition
private $factoryClass;
private $factoryMethod;
private $factoryService;
- private $scope;
- private $properties;
- private $calls;
+ private $scope = ContainerInterface::SCOPE_CONTAINER;
+ private $properties = array();
+ private $calls = array();
private $configurator;
- private $tags;
- private $public;
- private $synthetic;
- private $abstract;
- private $synchronized;
- private $lazy;
+ private $tags = array();
+ private $public = true;
+ private $synthetic = false;
+ private $abstract = false;
+ private $synchronized = false;
+ private $lazy = false;
protected $arguments;
/**
* Constructor.
*
- * @param string $class The service class
- * @param array $arguments An array of arguments to pass to the service constructor
+ * @param string|null $class The service class
+ * @param array $arguments An array of arguments to pass to the service constructor
*
* @api
*/
@@ -53,15 +53,6 @@ public function __construct($class = null, array $arguments = array())
{
$this->class = $class;
$this->arguments = $arguments;
- $this->calls = array();
- $this->scope = ContainerInterface::SCOPE_CONTAINER;
- $this->tags = array();
- $this->public = true;
- $this->synthetic = false;
- $this->synchronized = false;
- $this->lazy = false;
- $this->abstract = false;
- $this->properties = array();
}
/**
@@ -84,7 +75,7 @@ public function setFactoryClass($factoryClass)
/**
* Gets the factory class.
*
- * @return string The factory class name
+ * @return string|null The factory class name
*
* @api
*/
@@ -112,7 +103,7 @@ public function setFactoryMethod($factoryMethod)
/**
* Gets the factory method.
*
- * @return string The factory method name
+ * @return string|null The factory method name
*
* @api
*/
@@ -140,7 +131,7 @@ public function setFactoryService($factoryService)
/**
* Gets the factory service id.
*
- * @return string The factory service id
+ * @return string|null The factory service id
*
* @api
*/
@@ -168,7 +159,7 @@ public function setClass($class)
/**
* Gets the service class.
*
- * @return string The service class
+ * @return string|null The service class
*
* @api
*/
@@ -508,7 +499,7 @@ public function setFile($file)
/**
* Gets the file to require before creating the service.
*
- * @return string The full pathname to include
+ * @return string|null The full pathname to include
*
* @api
*/
@@ -704,7 +695,7 @@ public function setConfigurator($callable)
/**
* Gets the configurator to call after the service is fully initialized.
*
- * @return callable The PHP callable to call
+ * @return callable|null The PHP callable to call
*
* @api
*/
View
3 src/Symfony/Component/DependencyInjection/DefinitionDecorator.php
@@ -24,7 +24,7 @@
class DefinitionDecorator extends Definition
{
private $parent;
- private $changes;
+ private $changes = array();
/**
* Constructor.
@@ -38,7 +38,6 @@ public function __construct($parent)
parent::__construct();
$this->parent = $parent;
- $this->changes = array();
}
/**
View
6 src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
@@ -24,8 +24,8 @@
*/
class ParameterBag implements ParameterBagInterface
{
- protected $parameters;
- protected $resolved;
+ protected $parameters = array();
+ protected $resolved = false;
/**
* Constructor.
@@ -36,9 +36,7 @@ class ParameterBag implements ParameterBagInterface
*/
public function __construct(array $parameters = array())
{
- $this->parameters = array();
$this->add($parameters);
- $this->resolved = false;
}
/**
View
2 src/Symfony/Component/EventDispatcher/Tests/EventTest.php
@@ -35,7 +35,7 @@ class EventTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
- $this->event = new Event;
+ $this->event = new Event();
$this->dispatcher = new EventDispatcher();
}
View
3 src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php
@@ -29,12 +29,11 @@ class ExpressionLanguage
private $parser;
private $compiler;
- protected $functions;
+ protected $functions = array();
public function __construct(ParserCacheInterface $cache = null)
{
$this->cache = $cache ?: new ArrayParserCache();
- $this->functions = array();
$this->registerFunctions();
}
View
12 src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php
@@ -16,9 +16,9 @@
class BinaryNode extends Node
{
private static $operators = array(
- '~' => '.',
- 'and' => '&&',
- 'or' => '||',
+ '~' => '.',
+ 'and' => '&&',
+ 'or' => '||',
);
private static $functions = array(
@@ -30,8 +30,10 @@ class BinaryNode extends Node
public function __construct($operator, Node $left, Node $right)
{
- $this->nodes = array('left' => $left, 'right' => $right);
- $this->attributes = array('operator' => $operator);
+ parent::__construct(
+ array('left' => $left, 'right' => $right),
+ array('operator' => $operator)
+ );
}
public function compile(Compiler $compiler)
View
4 src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php
@@ -17,7 +17,9 @@ class ConditionalNode extends Node
{
public function __construct(Node $expr1, Node $expr2, Node $expr3)
{
- $this->nodes = array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3);
+ parent::__construct(
+ array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3)
+ );
}
public function compile(Compiler $compiler)
View
5 src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php
@@ -17,7 +17,10 @@ class ConstantNode extends Node
{
public function __construct($value)
{
- $this->attributes = array('value' => $value);
+ parent::__construct(
+ array(),
+ array('value' => $value)
+ );
}
public function compile(Compiler $compiler)
View
6 src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php
@@ -17,8 +17,10 @@ class FunctionNode extends Node
{
public function __construct($name, Node $arguments)
{
- $this->nodes = array('arguments' => $arguments);
- $this->attributes = array('name' => $name);
+ parent::__construct(
+ array('arguments' => $arguments),
+ array('name' => $name)
+ );
}
public function compile(Compiler $compiler)
View
6 src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php
@@ -21,8 +21,10 @@ class GetAttrNode extends Node
public function __construct(Node $node, Node $attribute, ArrayNode $arguments, $type)
{
- $this->nodes = array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments);
- $this->attributes = array('type' => $type);
+ parent::__construct(
+ array('node' => $node, 'attribute' => $attribute, 'arguments' => $arguments),
+ array('type' => $type)
+ );
}
public function compile(Compiler $compiler)
View
5 src/Symfony/Component/ExpressionLanguage/Node/NameNode.php
@@ -17,7 +17,10 @@ class NameNode extends Node
{
public function __construct($name)
{
- $this->attributes = array('name' => $name);
+ parent::__construct(
+ array(),
+ array('name' => $name)
+ );
}
public function compile(Compiler $compiler)
View
6 src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php
@@ -24,8 +24,10 @@ class UnaryNode extends Node
public function __construct($operator, Node $node)
{
- $this->nodes = array('node' => $node);
- $this->attributes = array('operator' => $operator);
+ parent::__construct(
+ array('node' => $node),
+ array('operator' => $operator)
+ );
}
public function compile(Compiler $compiler)
View
3 src/Symfony/Component/ExpressionLanguage/TokenStream.php
@@ -21,7 +21,7 @@ class TokenStream
public $current;
private $tokens;
- private $position;
+ private $position = 0;
/**
* Constructor.
@@ -31,7 +31,6 @@ class TokenStream
public function __construct(array $tokens)
{
$this->tokens = $tokens;
- $this->position = 0;
$this->current = $tokens[0];
}
View
3 src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php
@@ -18,7 +18,7 @@
*/
class ExcludeDirectoryFilterIterator extends FilterIterator
{
- private $patterns;
+ private $patterns = array();
/**
* Constructor.
@@ -28,7 +28,6 @@ class ExcludeDirectoryFilterIterator extends FilterIterator
*/
public function __construct(\Iterator $iterator, array $directories)
{
- $this->patterns = array();
foreach ($directories as $directory) {
$this->patterns[] = '#(^|/)'.preg_quote($directory, '#').'(/|$)#';
}
View
6 src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php
@@ -20,8 +20,8 @@
*/
abstract class MultiplePcreFilterIterator extends FilterIterator
{
- protected $matchRegexps;
- protected $noMatchRegexps;
+ protected $matchRegexps = array();
+ protected $noMatchRegexps = array();
/**
* Constructor.
@@ -32,12 +32,10 @@
*/
public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
{
- $this->matchRegexps = array();
foreach ($matchPatterns as $pattern) {
$this->matchRegexps[] = $this->toRegex($pattern);
}
- $this->noMatchRegexps = array();
foreach ($noMatchPatterns as $pattern) {
$this->noMatchRegexps[] = $this->toRegex($pattern);
}
View
6 src/Symfony/Component/Finder/Shell/Command.php
@@ -24,12 +24,12 @@ class Command
/**
* @var array
*/
- private $bits;
+ private $bits = array();
/**
* @var array
*/
- private $labels;
+ private $labels = array();
/**
* @var \Closure|null
@@ -44,8 +44,6 @@ class Command
public function __construct(Command $parent = null)
{
$this->parent = $parent;
- $this->bits = array();
- $this->labels = array();
}
/**
View
3 src/Symfony/Component/Finder/Tests/Iterator/Iterator.php
@@ -13,11 +13,10 @@
class Iterator implements \Iterator
{
- protected $values;
+ protected $values = array();
public function __construct(array $values = array())
{
- $this->values = array();
foreach ($values as $value) {
$this->attach(new \SplFileInfo($value));
}
View
6 src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php
@@ -27,12 +27,12 @@ protected function setUp()
$this->registry->setAccessible(true);
$this->guesser = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface');
- $this->type = new FooType;
+ $this->type = new FooType();
}
public function testAddType()
{
- $factoryBuilder = new FormFactoryBuilder;
+ $factoryBuilder = new FormFactoryBuilder();
$factoryBuilder->addType($this->type);
$factory = $factoryBuilder->getFormFactory();
@@ -46,7 +46,7 @@ public function testAddType()
public function testAddTypeGuesser()
{
- $factoryBuilder = new FormFactoryBuilder;
+ $factoryBuilder = new FormFactoryBuilder();
$factoryBuilder->addTypeGuesser($this->guesser);
$factory = $factoryBuilder->getFormFactory();
View
6 src/Symfony/Component/HttpFoundation/HeaderBag.php
@@ -20,8 +20,8 @@
*/
class HeaderBag implements \IteratorAggregate, \Countable
{
- protected $headers;
- protected $cacheControl;
+ protected $headers = array();
+ protected $cacheControl = array();
/**
* Constructor.
@@ -32,8 +32,6 @@ class HeaderBag implements \IteratorAggregate, \Countable
*/
public function __construct(array $headers = array())
{
- $this->cacheControl = array();
- $this->headers = array();
foreach ($headers as $key => $values) {
$this->set($key, $values);
}
View
3 src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php
@@ -25,7 +25,7 @@ class AutoExpireFlashBag implements FlashBagInterface
*
* @var array
*/
- private $flashes = array();
+ private $flashes = array('display' => array(), 'new' => array());
/**
* The storage key for flashes in the session
@@ -42,7 +42,6 @@ class AutoExpireFlashBag implements FlashBagInterface
public function __construct($storageKey = '_sf2_flashes')
{
$this->storageKey = $storageKey;
- $this->flashes = array('display' => array(), 'new' => array());
}
/**
View
3 src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php
@@ -39,7 +39,7 @@ class MetadataBag implements SessionBagInterface
/**
* @var array
*/
- protected $meta = array();
+ protected $meta = array(self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0);
/**
* Unix timestamp.
@@ -63,7 +63,6 @@ public function __construct($storageKey = '_sf2_meta', $updateThreshold = 0)
{
$this->storageKey = $storageKey;
$this->updateThreshold = $updateThreshold;
- $this->meta = array(self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0);
}
/**
View
2 src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php
@@ -11,7 +11,7 @@
namespace Symfony\Component\HttpFoundation\Tests;
-use \Symfony\Component\HttpFoundation\RedirectResponse;
+use Symfony\Component\HttpFoundation\RedirectResponse;
class RedirectResponseTest extends \PHPUnit_Framework_TestCase
{
View
8 src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
@@ -881,14 +881,14 @@ public function testGetClientIpsProvider()
public function testGetContentWorksTwiceInDefaultMode()
{
- $req = new Request;
+ $req = new Request();
$this->assertEquals('', $req->getContent());
$this->assertEquals('', $req->getContent());
}
public function testGetContentReturnsResource()
{
- $req = new Request;
+ $req = new Request();
$retval = $req->getContent(true);
$this->assertInternalType('resource', $retval);
$this->assertEquals("", fread($retval, 1));
@@ -901,7 +901,7 @@ public function testGetContentReturnsResource()
*/
public function testGetContentCantBeCalledTwiceWithResources($first, $second)
{
- $req = new Request;
+ $req = new Request();
$req->getContent($first);
$req->getContent($second);
}
@@ -1361,7 +1361,7 @@ public function getBaseUrlData()
*/
public function testUrlencodedStringPrefix($string, $prefix, $expect)
{
- $request = new Request;
+ $request = new Request();
$me = new \ReflectionMethod($request, 'getUrlencodedPrefix');
$me->setAccessible(true);
View
2 src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php
@@ -758,7 +758,7 @@ public function testSettersAreChainable()
public function validContentProvider()
{
return array(
- 'obj' => array(new StringableObject),
+ 'obj' => array(new StringableObject()),
'string' => array('Foo'),
'int' => array(2),
);
View
2 src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php
@@ -59,7 +59,7 @@ protected function tearDown()
protected function getStorage(array $options = array())
{
$storage = new NativeSessionStorage($options);
- $storage->registerBag(new AttributeBag);
+ $storage->registerBag(new AttributeBag());
return $storage;
}
View
2 src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php
@@ -53,7 +53,7 @@ protected function tearDown()
protected function getStorage()
{
$storage = new PhpBridgeSessionStorage();
- $storage->registerBag(new AttributeBag);
+ $storage->registerBag(new AttributeBag());
return $storage;
}
View
9 src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php
@@ -18,13 +18,14 @@
*/
class CacheWarmerAggregate implements CacheWarmerInterface
{
- protected $warmers;
- protected $optionalsEnabled;
+ protected $warmers = array();
+ protected $optionalsEnabled = false;
public function __construct(array $warmers = array())
{
- $this->setWarmers($warmers);
- $this->optionalsEnabled = false;
+ foreach ($warmers as $warmer) {
+ $this->add($warmer);
+ }
}
public function enableOptionalWarmers()
View
3 src/Symfony/Component/HttpKernel/Client.php
@@ -43,10 +43,9 @@ class Client extends BaseClient
*/
public function __construct(HttpKernelInterface $kernel, array $server = array(), History $history = null, CookieJar $cookieJar = null)
{
- $this->kernel = $kernel;
-
parent::__construct($server, $history, $cookieJar);
+ $this->kernel = $kernel;
$this->followRedirects = false;
}
View
9 src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php
@@ -30,11 +30,11 @@
class TraceableEventDispatcher implements EventDispatcherInterface, TraceableEventDispatcherInterface
{
private $logger;
- private $called;
+ private $called = array();
private $stopwatch;
private $dispatcher;
- private $wrappedListeners;
- private $firstCalledEvent;
+ private $wrappedListeners = array();
+ private $firstCalledEvent = array();
private $id;
/**
@@ -49,9 +49,6 @@ public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $sto
$this->dispatcher = $dispatcher;
$this->stopwatch = $stopwatch;
$this->logger = $logger;
- $this->called = array();
- $this->wrappedListeners = array();
- $this->firstCalledEvent = array();
}
/**
View
3 src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php
@@ -33,7 +33,7 @@ class ProfilerListener implements EventSubscriberInterface
protected $onlyException;
protected $onlyMasterRequests;
protected $exception;
- protected $requests;
+ protected $requests = array();
protected $profiles;
protected $requestStack;
protected $parents;
@@ -54,7 +54,6 @@ public function __construct(Profiler $profiler, RequestMatcherInterface $matcher
$this->onlyMasterRequests = (Boolean) $onlyMasterRequests;
$this->profiles = new \SplObjectStorage();
$this->parents = new \SplObjectStorage();
- $this->requests = array();
$this->requestStack = $requestStack;
}
View
3 src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php
@@ -35,7 +35,7 @@
class FragmentHandler
{
private $debug;
- private $renderers;
+ private $renderers = array();
private $request;
private $requestStack;
@@ -51,7 +51,6 @@ class FragmentHandler
public function __construct(array $renderers = array(), $debug = false, RequestStack $requestStack = null)
{
$this->requestStack = $requestStack;
- $this->renderers = array();
foreach ($renderers as $renderer) {
$this->addRenderer($renderer);
}
View
6 src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
@@ -35,7 +35,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
private $request;
private $esi;
private $esiCacheStrategy;
- private $traces;
+ private $options = array();
+ private $traces = array();
/**
* Constructor.
@@ -81,6 +82,7 @@ public function __construct(HttpKernelInterface $kernel, StoreInterface $store,
{
$this->store = $store;
$this->kernel = $kernel;
+ $this->esi = $esi;
// needed in case there is a fatal error because the backend is too slow to respond
register_shutdown_function(array($this->store, 'cleanup'));
@@ -94,8 +96,6 @@ public function __construct(HttpKernelInterface $kernel, StoreInterface $store,
'stale_while_revalidate' => 2,
'stale_if_error' => 60,
), $options);
- $this->esi = $esi;
- $this->traces = array();
}
/**
View
6 src/Symfony/Component/HttpKernel/Kernel.php
@@ -48,14 +48,14 @@
/**
* @var BundleInterface[]
*/
- protected $bundles;
+ protected $bundles = array();
protected $bundleMap;
protected $container;
protected $rootDir;
protected $environment;
protected $debug;
- protected $booted;
+ protected $booted = false;
protected $name;
protected $startTime;
protected $loadClassCache;
@@ -79,10 +79,8 @@ public function __construct($environment, $debug)
{
$this->environment = $environment;
$this->debug = (Boolean) $debug;
- $this->booted = false;
$this->rootDir = $this->getRootDir();
$this->name = $this->getName();
- $this->bundles = array();
if ($this->debug) {
$this->startTime = microtime(true);
View
2 src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php
@@ -42,7 +42,7 @@ protected function getMemcache()
$host = $matches[1] ?: $matches[2];
$port = $matches[3];
- $memcache = new Memcache;
+ $memcache = new Memcache();
$memcache->addServer($host, $port);
$this->memcache = $memcache;
View
2 src/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php
@@ -42,7 +42,7 @@ protected function getMemcached()