Thanks to visit codestin.com
Credit goes to github.com

Skip to content

unify constructor initialization style throughout symfony #9487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/Symfony/Bridge/Twig/NodeVisitor/Scope.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class TemplateNameParser implements TemplateNameParserInterface
{
protected $kernel;
protected $cache;
protected $cache = array();

/**
* Constructor.
Expand All @@ -35,7 +35,6 @@ class TemplateNameParser implements TemplateNameParserInterface
public function __construct(KernelInterface $kernel)
{
$this->kernel = $kernel;
$this->cache = array();
}

/**
Expand Down
10 changes: 4 additions & 6 deletions src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
class Translator extends BaseTranslator
{
protected $container;
protected $options;
protected $options = array(
'cache_dir' => null,
'debug' => false,
);
protected $loaderIds;

/**
Expand All @@ -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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
class LogoutUrlHelper extends Helper
{
private $container;
private $listeners;
private $listeners = array();
private $router;

/**
Expand All @@ -39,7 +39,6 @@ public function __construct(ContainerInterface $container, UrlGeneratorInterface
{
$this->container = $container;
$this->router = $router;
$this->listeners = array();
}

/**
Expand Down
21 changes: 8 additions & 13 deletions src/Symfony/Component/BrowserKit/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ abstract class Client
{
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.
Expand All @@ -58,13 +58,8 @@ abstract class Client
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();
}

/**
Expand Down
8 changes: 0 additions & 8 deletions src/Symfony/Component/BrowserKit/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ class History
protected $stack = array();
protected $position = -1;

/**
* Constructor.
*/
public function __construct()
{
$this->clear();
}

/**
* Clears the history.
*/
Expand Down
36 changes: 8 additions & 28 deletions src/Symfony/Component/Config/Definition/ArrayNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
15 changes: 5 additions & 10 deletions src/Symfony/Component/Config/Definition/BaseNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ abstract class BaseNode implements NodeInterface
{
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();

/**
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
class MergeBuilder
{
protected $node;
public $allowFalse;
public $allowOverwrite;
public $allowFalse = false;
public $allowOverwrite = true;

/**
* Constructor
Expand All @@ -30,8 +30,6 @@ class MergeBuilder
public function __construct(NodeDefinition $node)
{
$this->node = $node;
$this->allowFalse = false;
$this->allowOverwrite = true;
}

/**
Expand Down
23 changes: 10 additions & 13 deletions src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,30 @@ abstract class NodeDefinition implements NodeParentInterface
protected $normalization;
protected $validation;
protected $defaultValue;
protected $default;
protected $required;
protected $default = false;
protected $required = false;
protected $merge;
protected $allowEmptyValue;
protected $allowEmptyValue = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this gave me some headache because you would think since it was not initialized (null) is means boolean false. but actually it must be true as tests showed

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;
}

/**
Expand Down Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
class NormalizationBuilder
{
protected $node;
public $before;
public $remappings;
public $before = array();
public $remappings = array();

/**
* Constructor
Expand All @@ -30,9 +30,6 @@ class NormalizationBuilder
public function __construct(NodeDefinition $node)
{
$this->node = $node;
$this->keys = false;
$this->remappings = array();
$this->before = array();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not exist


/**
Expand Down
Loading