Permalink
Browse files

unify constructor initialization style throughout symfony

  • Loading branch information...
Tobion committed Nov 10, 2013
1 parent b9b7c8a commit 111ac18232dd660a3d23d9d0f1935aa914ffc43c
Showing with 214 additions and 397 deletions.
  1. +2 −3 src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
  2. +2 −4 src/Symfony/Bridge/Twig/NodeVisitor/Scope.php
  3. +1 −2 src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php
  4. +4 −6 src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
  5. +0 −2 src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
  6. +1 −2 src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php
  7. +8 −13 src/Symfony/Component/BrowserKit/Client.php
  8. +0 −8 src/Symfony/Component/BrowserKit/History.php
  9. +8 −28 src/Symfony/Component/Config/Definition/ArrayNode.php
  10. +5 −10 src/Symfony/Component/Config/Definition/BaseNode.php
  11. +8 −16 src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php
  12. +2 −4 src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php
  13. +10 −13 src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
  14. +2 −5 src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php
  15. +1 −3 src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php
  16. +1 −4 src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php
  17. +3 −17 src/Symfony/Component/Config/Definition/PrototypedArrayNode.php
  18. +1 −2 src/Symfony/Component/Config/Loader/LoaderResolver.php
  19. +1 −2 src/Symfony/Component/Console/Helper/HelperSet.php
  20. +5 −4 src/Symfony/Component/Console/Input/Input.php
  21. +1 −2 src/Symfony/Component/Console/Shell.php
  22. +1 −2 src/Symfony/Component/CssSelector/Parser/Reader.php
  23. +1 −2 src/Symfony/Component/DependencyInjection/Compiler/Compiler.php
  24. +3 −7 src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
  25. +1 −9 src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php
  26. +2 −4 src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php
  27. +8 −15 src/Symfony/Component/DependencyInjection/Container.php
  28. +17 −26 src/Symfony/Component/DependencyInjection/Definition.php
  29. +1 −2 src/Symfony/Component/DependencyInjection/DefinitionDecorator.php
  30. +2 −4 src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php
  31. +1 −2 src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php
  32. +7 −5 src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php
  33. +3 −1 src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php
  34. +4 −1 src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php
  35. +4 −2 src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php
  36. +4 −2 src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php
  37. +4 −1 src/Symfony/Component/ExpressionLanguage/Node/NameNode.php
  38. +4 −2 src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php
  39. +1 −2 src/Symfony/Component/ExpressionLanguage/TokenStream.php
  40. +1 −2 src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php
  41. +2 −4 src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php
  42. +2 −4 src/Symfony/Component/Finder/Shell/Command.php
  43. +1 −2 src/Symfony/Component/Finder/Tests/Iterator/Iterator.php
  44. +2 −4 src/Symfony/Component/HttpFoundation/HeaderBag.php
  45. +1 −2 src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php
  46. +1 −2 src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php
  47. +5 −4 src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php
  48. +1 −2 src/Symfony/Component/HttpKernel/Client.php
  49. +3 −6 src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php
  50. +1 −2 src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php
  51. +1 −2 src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php
  52. +3 −3 src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
  53. +2 −4 src/Symfony/Component/HttpKernel/Kernel.php
  54. +2 −4 src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php
  55. +4 −10 src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php
  56. +2 −8 src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php
  57. +2 −8 src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php
  58. +2 −9 src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php
  59. +4 −9 src/Symfony/Component/Process/ProcessBuilder.php
  60. +5 −11 src/Symfony/Component/Routing/Annotation/Route.php
  61. +2 −4 src/Symfony/Component/Security/Acl/Dbal/AclProvider.php
  62. +5 −11 src/Symfony/Component/Security/Acl/Domain/Acl.php
  63. +3 −7 src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php
  64. +1 −2 src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php
  65. +6 −8 src/Symfony/Component/Stopwatch/StopwatchEvent.php
  66. +3 −3 src/Symfony/Component/Stopwatch/StopwatchPeriod.php
  67. +1 −2 src/Symfony/Component/Templating/DelegatingEngine.php
  68. +1 −2 src/Symfony/Component/Templating/Helper/CoreAssetsHelper.php
  69. +1 −2 src/Symfony/Component/Templating/Loader/ChainLoader.php
  70. +9 −14 src/Symfony/Component/Templating/PhpEngine.php
  71. +1 −1 src/Symfony/Component/Validator/Constraints/Collection.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
@@ -29,21 +29,19 @@ class Scope
/**
* @var array
*/
- private $data;
+ private $data = array();
/**
* @var boolean
*/
- private $left;
+ private $left = false;
/**
* @param Scope $parent
*/
public function __construct(Scope $parent = null)
{
$this->parent = $parent;
- $this->left = false;
- $this->data = array();
}
/**
@@ -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();
}
/**
@@ -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)));
@@ -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;
/**
@@ -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();
}
/**
@@ -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();
}
/**
@@ -21,14 +21,6 @@ class History
protected $stack = array();
protected $position = -1;
- /**
- * Constructor.
- */
- public function __construct()
- {
- $this->clear();
- }
-
/**
* Clears the history.
*/
@@ -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)
{
@@ -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)
@@ -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;
}
/**
@@ -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;
}
/**
@@ -25,33 +25,30 @@
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();
/**
* 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()
{
@@ -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();
}
/**
Oops, something went wrong.

0 comments on commit 111ac18

Please sign in to comment.