diff --git a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php b/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php index cd8f883f4975a..fe00e4cd55ad6 100644 --- a/src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php +++ b/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 diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php b/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php index ce27b6a6b209d..12ad604d35076 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php +++ b/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(); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php b/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php index 5777479d4dde6..8b04248999133 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/Router.php +++ b/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); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php index ef2ae0800886a..8481dc78e7a9b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php +++ b/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(); } /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php b/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php index 1705c1ac06c18..b4b3acdfb47b9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Translation/Translator.php +++ b/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))); diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index aaa3a731527e3..86e9d8fbd8bb8 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/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; /** diff --git a/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php b/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php index 6400ed20e0918..50434bda0befd 100644 --- a/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php +++ b/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(); } /** diff --git a/src/Symfony/Component/BrowserKit/Client.php b/src/Symfony/Component/BrowserKit/Client.php index 06f43e190b163..cd9324b26bf3a 100644 --- a/src/Symfony/Component/BrowserKit/Client.php +++ b/src/Symfony/Component/BrowserKit/Client.php @@ -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. @@ -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(); } /** diff --git a/src/Symfony/Component/BrowserKit/History.php b/src/Symfony/Component/BrowserKit/History.php index a22847ef1395f..0c79d5b525125 100644 --- a/src/Symfony/Component/BrowserKit/History.php +++ b/src/Symfony/Component/BrowserKit/History.php @@ -21,14 +21,6 @@ class History protected $stack = array(); protected $position = -1; - /** - * Constructor. - */ - public function __construct() - { - $this->clear(); - } - /** * Clears the history. */ diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index 7e5f684c62959..4056bfcce75bb 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/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) { diff --git a/src/Symfony/Component/Config/Definition/BaseNode.php b/src/Symfony/Component/Config/Definition/BaseNode.php index 9b692888c8f42..3e4412713fc57 100644 --- a/src/Symfony/Component/Config/Definition/BaseNode.php +++ b/src/Symfony/Component/Config/Definition/BaseNode.php @@ -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(); /** @@ -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) diff --git a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php index a658050ea6158..e436b0bd1382b 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ArrayNodeDefinition.php +++ b/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; } /** diff --git a/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php b/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php index 5e09ff5ca0905..88311433399eb 100644 --- a/src/Symfony/Component/Config/Definition/Builder/MergeBuilder.php +++ b/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; } /** diff --git a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php index 289e1c4f4d777..a9dcb09fecd8b 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php +++ b/src/Symfony/Component/Config/Definition/Builder/NodeDefinition.php @@ -25,15 +25,16 @@ 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; 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 @@ abstract class NodeDefinition implements NodeParentInterface /** * 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() { diff --git a/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php b/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php index 87f25b723a28e..4020f605d1df9 100644 --- a/src/Symfony/Component/Config/Definition/Builder/NormalizationBuilder.php +++ b/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(); } /** diff --git a/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php b/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php index 22f54a1091b90..56d6ddc34b221 100644 --- a/src/Symfony/Component/Config/Definition/Builder/ValidationBuilder.php +++ b/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(); } /** diff --git a/src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php b/src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php index 75da3ab87bfca..9c6e249c95288 100644 --- a/src/Symfony/Component/Config/Definition/Builder/VariableNodeDefinition.php +++ b/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); diff --git a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php index 2e76156574efb..7074cb362e87e 100644 --- a/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php +++ b/src/Symfony/Component/Config/Definition/PrototypedArrayNode.php @@ -25,25 +25,11 @@ 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. diff --git a/src/Symfony/Component/Config/Loader/LoaderResolver.php b/src/Symfony/Component/Config/Loader/LoaderResolver.php index 2340fe07f8869..9e1ebd4f2a908 100644 --- a/src/Symfony/Component/Config/Loader/LoaderResolver.php +++ b/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); } diff --git a/src/Symfony/Component/Console/Helper/HelperSet.php b/src/Symfony/Component/Console/Helper/HelperSet.php index c317293d04106..e080678bce86b 100644 --- a/src/Symfony/Component/Console/Helper/HelperSet.php +++ b/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); } diff --git a/src/Symfony/Component/Console/Input/Input.php b/src/Symfony/Component/Console/Input/Input.php index fb84cf829e3d6..a55029ec19883 100644 --- a/src/Symfony/Component/Console/Input/Input.php +++ b/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 @@ abstract class Input implements InputInterface public function __construct(InputDefinition $definition = null) { if (null === $definition) { - $this->arguments = array(); - $this->options = array(); $this->definition = new InputDefinition(); } else { $this->bind($definition); diff --git a/src/Symfony/Component/Console/Output/Output.php b/src/Symfony/Component/Console/Output/Output.php index b2ee4ddaf3007..94b9c88d76d91 100644 --- a/src/Symfony/Component/Console/Output/Output.php +++ b/src/Symfony/Component/Console/Output/Output.php @@ -46,7 +46,7 @@ abstract class Output implements OutputInterface 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); } diff --git a/src/Symfony/Component/Console/Shell.php b/src/Symfony/Component/Console/Shell.php index ff8bef5f74f96..5ddbd27536b4c 100644 --- a/src/Symfony/Component/Console/Shell.php +++ b/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; } /** diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index ba597a0fc64d4..42cc91f78084f 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -840,7 +840,7 @@ public function testTerminalDimensions() protected function getDispatcher() { - $dispatcher = new EventDispatcher; + $dispatcher = new EventDispatcher(); $dispatcher->addListener('console.command', function (ConsoleCommandEvent $event) { $event->getOutput()->write('before.'); }); diff --git a/src/Symfony/Component/CssSelector/Parser/Reader.php b/src/Symfony/Component/CssSelector/Parser/Reader.php index 8bd8ed66988ac..2a6c4bbd43964 100644 --- a/src/Symfony/Component/CssSelector/Parser/Reader.php +++ b/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; } /** diff --git a/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php b/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php index 01f224b823257..3918c9b1de4bf 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php +++ b/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(); } /** diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php index e863f75640fb1..ac395db22e9a2 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php +++ b/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(), diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php b/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php index fbd33eeee16f9..1de14fa62f96b 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraph.php +++ b/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. diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php b/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php index 3fd50771d54e2..283f6de5ba0ef 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ServiceReferenceGraphNode.php +++ b/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(); } /** diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 8c178169eae57..c7056297a6df7 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/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); } diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index 1168444389ef1..428fee27c3a21 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/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 */ diff --git a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php b/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php index 1f72b8f16b2e8..b7eed8c564d4d 100644 --- a/src/Symfony/Component/DependencyInjection/DefinitionDecorator.php +++ b/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(); } /** diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index 494d231e9f29f..dabd1c6215673 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/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; } /** diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventTest.php index 52aa9ad68a8f4..69c6aa3004b85 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventTest.php +++ b/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(); } diff --git a/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php b/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php index b0f0b39526bbc..962c006e412bc 100644 --- a/src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php +++ b/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(); } diff --git a/src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php b/src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php index a72e52716a008..15341e86c536e 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php +++ b/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) diff --git a/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php b/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php index b77dcc5aada3b..7de1e3de12691 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php +++ b/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) diff --git a/src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php b/src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php index fcc1ce6fb607f..7842e5787776c 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/ConstantNode.php +++ b/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) diff --git a/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php b/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php index a7b090591ab8d..4a290a488d98c 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php +++ b/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) diff --git a/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php b/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php index 2f1156ca766fb..441eb3c8e63af 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/GetAttrNode.php +++ b/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) diff --git a/src/Symfony/Component/ExpressionLanguage/Node/NameNode.php b/src/Symfony/Component/ExpressionLanguage/Node/NameNode.php index dbd0c780d9022..3d39f4077ece4 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/NameNode.php +++ b/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) diff --git a/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php b/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php index 73aef144aff90..fd980e5b7a88c 100644 --- a/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php +++ b/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) diff --git a/src/Symfony/Component/ExpressionLanguage/TokenStream.php b/src/Symfony/Component/ExpressionLanguage/TokenStream.php index 7a75f96648f02..8516273a661d1 100644 --- a/src/Symfony/Component/ExpressionLanguage/TokenStream.php +++ b/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]; } diff --git a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php index 42c8ce760d26f..e4eabbf804bbe 100644 --- a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php +++ b/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, '#').'(/|$)#'; } diff --git a/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php b/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php index 3a9dd55582859..df6d6dc6a7bd9 100644 --- a/src/Symfony/Component/Finder/Iterator/MultiplePcreFilterIterator.php +++ b/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 @@ abstract class MultiplePcreFilterIterator extends FilterIterator */ 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); } diff --git a/src/Symfony/Component/Finder/Shell/Command.php b/src/Symfony/Component/Finder/Shell/Command.php index 5fcfed803feec..0cb5db47d7ed9 100644 --- a/src/Symfony/Component/Finder/Shell/Command.php +++ b/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(); } /** diff --git a/src/Symfony/Component/Finder/Tests/Iterator/Iterator.php b/src/Symfony/Component/Finder/Tests/Iterator/Iterator.php index 7ffd38267b99f..849bf081e2cc9 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/Iterator.php +++ b/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)); } diff --git a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php b/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php index a1292dbe72287..2c3ab000ffe30 100644 --- a/src/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php +++ b/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(); diff --git a/src/Symfony/Component/HttpFoundation/HeaderBag.php b/src/Symfony/Component/HttpFoundation/HeaderBag.php index b579eb991a146..2b9ef0e443e15 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderBag.php +++ b/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); } diff --git a/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php b/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php index c6e41de62e287..25a62604d2607 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php +++ b/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()); } /** diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php index 9bbdd082f1b86..44212979c307d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/MetadataBag.php +++ b/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); } /** diff --git a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php index 330d9fee51fbf..2a097d6fd422a 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RedirectResponseTest.php +++ b/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 { diff --git a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php b/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php index 9d1dcbe441dc2..23c3cbaa42117 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/RequestTest.php +++ b/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); diff --git a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php index 24fa653ba8df7..1a37101246144 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/ResponseTest.php +++ b/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), ); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 31dd41ab00f27..a9d93122412f9 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/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; } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php index d5a66d61efc5f..ebb555362c25c 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/PhpBridgeSessionStorageTest.php +++ b/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; } diff --git a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php index eb26ac59e62dc..bd96057ded64c 100644 --- a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php +++ b/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() diff --git a/src/Symfony/Component/HttpKernel/Client.php b/src/Symfony/Component/HttpKernel/Client.php index 13e6d50cdc6f9..8ebfb4174a22e 100644 --- a/src/Symfony/Component/HttpKernel/Client.php +++ b/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; } diff --git a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php index f5c13c7d752ce..fe4ad29851bb9 100644 --- a/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php +++ b/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(); } /** diff --git a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php b/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php index c4004b607c0a0..52e7dda5604dc 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ProfilerListener.php +++ b/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; } diff --git a/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php b/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php index bf60804ce8a4a..0297304844397 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/FragmentHandler.php +++ b/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); } diff --git a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php b/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php index 76691a542c9c9..de81581d79708 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php +++ b/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(); } /** diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 01091bf422858..a5cd1ad558d01 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -48,14 +48,14 @@ abstract class Kernel implements KernelInterface, TerminableInterface /** * @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); diff --git a/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php index a78cec0c8a327..2034a19db1e6b 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/MemcacheProfilerStorage.php +++ b/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; diff --git a/src/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php b/src/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php index f7f68423589a4..31f3136390851 100644 --- a/src/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php +++ b/src/Symfony/Component/HttpKernel/Profiler/MemcachedProfilerStorage.php @@ -42,7 +42,7 @@ protected function getMemcached() $host = $matches[1] ?: $matches[2]; $port = $matches[3]; - $memcached = new Memcached; + $memcached = new Memcached(); //disable compression to allow appending $memcached->setOption(Memcached::OPT_COMPRESSION, false); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php index fceab26c2dcec..b5d64bffe350a 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/TimeDataCollectorTest.php @@ -19,7 +19,7 @@ class TimeDataCollectorTest extends \PHPUnit_Framework_TestCase { public function testCollect() { - $c = new TimeDataCollector; + $c = new TimeDataCollector(); $request = new Request(); $request->server->set('REQUEST_TIME', 1); @@ -35,7 +35,7 @@ public function testCollect() $this->assertEquals(2000, $c->getStartTime()); $request = new Request(); - $c->collect($request, new Response); + $c->collect($request, new Response()); $this->assertEquals(0, $c->getStartTime()); $kernel = $this->getMock('Symfony\Component\HttpKernel\KernelInterface'); diff --git a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php index e24daef2b353a..5fd61bbc7e7ce 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php @@ -23,32 +23,15 @@ public function getBundleMap() public function registerBundles() { - } - - public function init() - { - } - - public function registerBundleDirs() - { + return array(); } public function registerContainerConfiguration(LoaderInterface $loader) { } - public function initializeBundles() - { - parent::initializeBundles(); - } - public function isBooted() { return $this->booted; } - - public function setIsBooted($value) - { - $this->booted = (Boolean) $value; - } } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php index cf23d7bf8abf7..da8c34c177680 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestHttpKernel.php @@ -23,9 +23,9 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface protected $body; protected $status; protected $headers; - protected $called; + protected $called = false; protected $customizer; - protected $catch; + protected $catch = false; protected $backendRequest; public function __construct($body, $status, $headers, \Closure $customizer = null) @@ -34,8 +34,6 @@ public function __construct($body, $status, $headers, \Closure $customizer = nul $this->status = $status; $this->headers = $headers; $this->customizer = $customizer; - $this->called = false; - $this->catch = false; parent::__construct(new EventDispatcher(), $this); } diff --git a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php index 6dd3d9e499d61..89ef406bbb15f 100644 --- a/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/Tests/HttpCache/TestMultipleHttpKernel.php @@ -20,20 +20,14 @@ class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInterface { - protected $bodies; - protected $statuses; - protected $headers; - protected $catch; - protected $call; + protected $bodies = array(); + protected $statuses = array(); + protected $headers = array(); + protected $call = false; protected $backendRequest; public function __construct($responses) { - $this->bodies = array(); - $this->statuses = array(); - $this->headers = array(); - $this->call = false; - foreach ($responses as $response) { $this->bodies[] = $response['body']; $this->statuses[] = $response['status']; diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index a3526913f9c1e..fb84b6a1f990e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -12,7 +12,6 @@ namespace Symfony\Component\HttpKernel\Tests; use Symfony\Component\HttpKernel\Kernel; -use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -52,33 +51,22 @@ public function testClone() public function testBootInitializesBundlesAndContainer() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) - ->getMock(); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); $kernel->expects($this->once()) ->method('initializeBundles'); $kernel->expects($this->once()) ->method('initializeContainer'); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array())); $kernel->boot(); } public function testBootSetsTheContainerToTheBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle') - ->disableOriginalConstructor() - ->getMock(); + $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); $bundle->expects($this->once()) ->method('setContainer'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) - ->getMock(); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'getBundles')); $kernel->expects($this->once()) ->method('getBundles') ->will($this->returnValue(array($bundle))); @@ -88,13 +76,11 @@ public function testBootSetsTheContainerToTheBundles() public function testBootSetsTheBootedFlagToTrue() { + // use test kernel to access isBooted() $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) + ->setConstructorArgs(array('test', false)) + ->setMethods(array('initializeBundles', 'initializeContainer')) ->getMock(); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array())); $kernel->boot(); @@ -103,14 +89,8 @@ public function testBootSetsTheBootedFlagToTrue() public function testClassCacheIsLoaded() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles', 'doLoadClassCache')) - ->getMock(); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); $kernel->loadClassCache('name', '.extension'); - $kernel->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array())); $kernel->expects($this->once()) ->method('doLoadClassCache') ->with('name', '.extension'); @@ -120,13 +100,7 @@ public function testClassCacheIsLoaded() public function testClassCacheIsNotLoadedByDefault() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles', 'doLoadClassCache')) - ->getMock(); - $kernel->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array())); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); $kernel->expects($this->never()) ->method('doLoadClassCache'); @@ -135,27 +109,17 @@ public function testClassCacheIsNotLoadedByDefault() public function testClassCacheIsNotLoadedWhenKernelIsNotBooted() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles', 'doLoadClassCache')) - ->getMock(); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer', 'doLoadClassCache')); $kernel->loadClassCache(); - $kernel->expects($this->any()) - ->method('getBundles') - ->will($this->returnValue(array())); $kernel->expects($this->never()) ->method('doLoadClassCache'); } public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('initializeBundles', 'initializeContainer', 'getBundles')) - ->getMock(); + $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array())); + ->method('initializeBundles'); $kernel->boot(); $kernel->boot(); @@ -163,40 +127,29 @@ public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() public function testShutdownCallsShutdownOnAllBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle') - ->disableOriginalConstructor() - ->getMock(); + $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); $bundle->expects($this->once()) ->method('shutdown'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getBundles')) - ->getMock(); - $kernel->expects($this->once()) - ->method('getBundles') - ->will($this->returnValue(array($bundle))); + $kernel = $this->getKernel(array(), array($bundle)); + $kernel->boot(); $kernel->shutdown(); } public function testShutdownGivesNullContainerToAllBundles() { - $bundle = $this->getMockBuilder('Symfony\Component\HttpKernel\Bundle\Bundle') - ->disableOriginalConstructor() - ->getMock(); - $bundle->expects($this->once()) + $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\Bundle'); + $bundle->expects($this->at(3)) ->method('setContainer') ->with(null); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getBundles')) - ->getMock(); - $kernel->expects($this->once()) + $kernel = $this->getKernel(array('getBundles')); + $kernel->expects($this->any()) ->method('getBundles') ->will($this->returnValue(array($bundle))); + $kernel->boot(); $kernel->shutdown(); } @@ -214,11 +167,7 @@ public function testHandleCallsHandleOnHttpKernel() ->method('handle') ->with($request, $type, $catch); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - + $kernel = $this->getKernel(array('getHttpKernel')); $kernel->expects($this->once()) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); @@ -236,11 +185,7 @@ public function testHandleBootsTheKernel() ->disableOriginalConstructor() ->getMock(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel', 'boot')) - ->getMock(); - + $kernel = $this->getKernel(array('getHttpKernel', 'boot')); $kernel->expects($this->once()) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); @@ -248,10 +193,6 @@ public function testHandleBootsTheKernel() $kernel->expects($this->once()) ->method('boot'); - // required as this value is initialized - // in the kernel constructor, which we don't call - $kernel->setIsBooted(false); - $kernel->handle($request, $type, $catch); } @@ -362,10 +303,7 @@ protected function getKernelMockForIsClassInActiveBundleTest() { $bundle = new FooBarBundle(); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getBundles')) - ->getMock(); + $kernel = $this->getKernel(array('getBundles')); $kernel->expects($this->once()) ->method('getBundles') ->will($this->returnValue(array($bundle))); @@ -409,7 +347,7 @@ public function testSerialize() */ public function testLocateResourceThrowsExceptionWhenNameIsNotValid() { - $this->getKernelForInvalidLocateResource()->locateResource('Foo'); + $this->getKernel()->locateResource('Foo'); } /** @@ -417,7 +355,7 @@ public function testLocateResourceThrowsExceptionWhenNameIsNotValid() */ public function testLocateResourceThrowsExceptionWhenNameIsUnsafe() { - $this->getKernelForInvalidLocateResource()->locateResource('@FooBundle/../bar'); + $this->getKernel()->locateResource('@FooBundle/../bar'); } /** @@ -425,7 +363,7 @@ public function testLocateResourceThrowsExceptionWhenNameIsUnsafe() */ public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist() { - $this->getKernelForInvalidLocateResource()->locateResource('@FooBundle/config/routing.xml'); + $this->getKernel()->locateResource('@FooBundle/config/routing.xml'); } /** @@ -433,7 +371,7 @@ public function testLocateResourceThrowsExceptionWhenBundleDoesNotExist() */ public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -445,7 +383,7 @@ public function testLocateResourceThrowsExceptionWhenResourceDoesNotExist() public function testLocateResourceReturnsTheFirstThatMatches() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -460,7 +398,7 @@ public function testLocateResourceReturnsTheFirstThatMatchesWithParent() $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->exactly(2)) ->method('getBundle') @@ -476,7 +414,7 @@ public function testLocateResourceReturnsAllMatches() $parent = $this->getBundle(__DIR__.'/Fixtures/Bundle1Bundle'); $child = $this->getBundle(__DIR__.'/Fixtures/Bundle2Bundle'); - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -491,7 +429,7 @@ public function testLocateResourceReturnsAllMatches() public function testLocateResourceReturnsAllMatchesBis() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -509,7 +447,7 @@ public function testLocateResourceReturnsAllMatchesBis() public function testLocateResourceIgnoresDirOnNonResource() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -524,7 +462,7 @@ public function testLocateResourceIgnoresDirOnNonResource() public function testLocateResourceReturnsTheDirOneForResources() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -539,7 +477,7 @@ public function testLocateResourceReturnsTheDirOneForResources() public function testLocateResourceReturnsTheDirOneForResourcesAndBundleOnes() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->once()) ->method('getBundle') @@ -558,7 +496,7 @@ public function testLocateResourceOverrideBundleAndResourcesFolders() $parent = $this->getBundle(__DIR__.'/Fixtures/BaseBundle', null, 'BaseBundle', 'BaseBundle'); $child = $this->getBundle(__DIR__.'/Fixtures/ChildBundle', 'ParentBundle', 'ChildBundle', 'ChildBundle'); - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->exactly(4)) ->method('getBundle') @@ -593,7 +531,7 @@ public function testLocateResourceOverrideBundleAndResourcesFolders() public function testLocateResourceOnDirectories() { - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->exactly(2)) ->method('getBundle') @@ -609,7 +547,7 @@ public function testLocateResourceOnDirectories() $kernel->locateResource('@FooBundle/Resources', __DIR__.'/Fixtures/Resources') ); - $kernel = $this->getKernel(); + $kernel = $this->getKernel(array('getBundle')); $kernel ->expects($this->exactly(2)) ->method('getBundle') @@ -631,13 +569,19 @@ public function testInitializeBundles() $parent = $this->getBundle(null, null, 'ParentABundle'); $child = $this->getBundle(null, 'ParentABundle', 'ChildABundle'); - $kernel = $this->getKernel(); + // use test kernel so we can access getBundleMap() + $kernel = $this + ->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') + ->setMethods(array('registerBundles')) + ->setConstructorArgs(array('test', false)) + ->getMock() + ; $kernel ->expects($this->once()) ->method('registerBundles') ->will($this->returnValue(array($parent, $child))) ; - $kernel->initializeBundles(); + $kernel->boot(); $map = $kernel->getBundleMap(); $this->assertEquals(array($child, $parent), $map['ParentABundle']); @@ -649,14 +593,20 @@ public function testInitializeBundlesSupportInheritanceCascade() $parent = $this->getBundle(null, 'GrandParentBBundle', 'ParentBBundle'); $child = $this->getBundle(null, 'ParentBBundle', 'ChildBBundle'); - $kernel = $this->getKernel(); + // use test kernel so we can access getBundleMap() + $kernel = $this + ->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') + ->setMethods(array('registerBundles')) + ->setConstructorArgs(array('test', false)) + ->getMock() + ; $kernel ->expects($this->once()) ->method('registerBundles') ->will($this->returnValue(array($grandparent, $parent, $child))) ; - $kernel->initializeBundles(); + $kernel->boot(); $map = $kernel->getBundleMap(); $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentBBundle']); @@ -666,18 +616,13 @@ public function testInitializeBundlesSupportInheritanceCascade() /** * @expectedException \LogicException + * @expectedExceptionMessage Bundle "ChildCBundle" extends bundle "FooBar", which is not registered. */ public function testInitializeBundlesThrowsExceptionWhenAParentDoesNotExists() { $child = $this->getBundle(null, 'FooBar', 'ChildCBundle'); - - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($child))) - ; - $kernel->initializeBundles(); + $kernel = $this->getKernel(array(), array($child)); + $kernel->boot(); } public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() @@ -686,14 +631,20 @@ public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() $parent = $this->getBundle(null, 'GrandParentCBundle', 'ParentCBundle'); $child = $this->getBundle(null, 'ParentCBundle', 'ChildCBundle'); - $kernel = $this->getKernel(); + // use test kernel so we can access getBundleMap() + $kernel = $this + ->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') + ->setMethods(array('registerBundles')) + ->setConstructorArgs(array('test', false)) + ->getMock() + ; $kernel ->expects($this->once()) ->method('registerBundles') ->will($this->returnValue(array($parent, $grandparent, $child))) ; - $kernel->initializeBundles(); + $kernel->boot(); $map = $kernel->getBundleMap(); $this->assertEquals(array($child, $parent, $grandparent), $map['GrandParentCBundle']); @@ -703,6 +654,7 @@ public function testInitializeBundlesSupportsArbitraryBundleRegistrationOrder() /** * @expectedException \LogicException + * @expectedExceptionMessage Bundle "ParentCBundle" is directly extended by two bundles "ChildC2Bundle" and "ChildC1Bundle". */ public function testInitializeBundlesThrowsExceptionWhenABundleIsDirectlyExtendedByTwoBundles() { @@ -710,59 +662,41 @@ public function testInitializeBundlesThrowsExceptionWhenABundleIsDirectlyExtende $child1 = $this->getBundle(null, 'ParentCBundle', 'ChildC1Bundle'); $child2 = $this->getBundle(null, 'ParentCBundle', 'ChildC2Bundle'); - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($parent, $child1, $child2))) - ; - $kernel->initializeBundles(); + $kernel = $this->getKernel(array(), array($parent, $child1, $child2)); + $kernel->boot(); } /** * @expectedException \LogicException + * @expectedExceptionMessage Trying to register two bundles with the same name "DuplicateName" */ public function testInitializeBundleThrowsExceptionWhenRegisteringTwoBundlesWithTheSameName() { $fooBundle = $this->getBundle(null, null, 'FooBundle', 'DuplicateName'); $barBundle = $this->getBundle(null, null, 'BarBundle', 'DuplicateName'); - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($fooBundle, $barBundle))) - ; - $kernel->initializeBundles(); + $kernel = $this->getKernel(array(), array($fooBundle, $barBundle)); + $kernel->boot(); } /** * @expectedException \LogicException + * @expectedExceptionMessage Bundle "CircularRefBundle" can not extend itself. */ public function testInitializeBundleThrowsExceptionWhenABundleExtendsItself() { $circularRef = $this->getBundle(null, 'CircularRefBundle', 'CircularRefBundle'); - $kernel = $this->getKernel(); - $kernel - ->expects($this->once()) - ->method('registerBundles') - ->will($this->returnValue(array($circularRef))) - ; - $kernel->initializeBundles(); + $kernel = $this->getKernel(array(), array($circularRef)); + $kernel->boot(); } public function testTerminateReturnsSilentlyIfKernelIsNotBooted() { - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - + $kernel = $this->getKernel(array('getHttpKernel')); $kernel->expects($this->never()) ->method('getHttpKernel'); - $kernel->setIsBooted(false); $kernel->terminate(Request::create('/'), new Response()); } @@ -777,16 +711,12 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() ->expects($this->never()) ->method('terminate'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - + $kernel = $this->getKernel(array('getHttpKernel')); $kernel->expects($this->once()) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); - $kernel->setIsBooted(true); + $kernel->boot(); $kernel->terminate(Request::create('/'), new Response()); // implements TerminableInterface @@ -799,19 +729,20 @@ public function testTerminateDelegatesTerminationOnlyForTerminableInterface() ->expects($this->once()) ->method('terminate'); - $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->disableOriginalConstructor() - ->setMethods(array('getHttpKernel')) - ->getMock(); - + $kernel = $this->getKernel(array('getHttpKernel')); $kernel->expects($this->exactly(2)) ->method('getHttpKernel') ->will($this->returnValue($httpKernelMock)); - $kernel->setIsBooted(true); + $kernel->boot(); $kernel->terminate(Request::create('/'), new Response()); } + /** + * Returns a mock for the BundleInterface + * + * @return BundleInterface + */ protected function getBundle($dir = null, $parent = null, $className = null, $bundleName = null) { $bundle = $this @@ -847,22 +778,28 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu return $bundle; } - protected function getKernel() - { - return $this - ->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') - ->setMethods(array('getBundle', 'registerBundles')) - ->disableOriginalConstructor() - ->getMock() - ; - } - - protected function getKernelForInvalidLocateResource() + /** + * Returns a mock for the abstract kernel. + * + * @param array $methods Additional methods to mock (besides the abstract ones) + * @param array $bundles Bundles to register + * + * @return Kernel + */ + protected function getKernel(array $methods = array(), array $bundles = array()) { - return $this + $kernel = $this ->getMockBuilder('Symfony\Component\HttpKernel\Kernel') - ->disableOriginalConstructor() + ->setMethods($methods) + ->setConstructorArgs(array('test', false)) ->getMockForAbstractClass() ; + + $kernel->expects($this->any()) + ->method('registerBundles') + ->will($this->returnValue($bundles)) + ; + + return $kernel; } } diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php index 014f5492fc8e9..9ff962c5b75e7 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcacheMock.php @@ -18,14 +18,8 @@ */ class MemcacheMock { - private $connected; - private $storage; - - public function __construct() - { - $this->connected = false; - $this->storage = array(); - } + private $connected = false; + private $storage = array(); /** * Open memcached server connection diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php index 2b17d70d2832e..d28d54211d111 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/MemcachedMock.php @@ -18,14 +18,8 @@ */ class MemcachedMock { - private $connected; - private $storage; - - public function __construct() - { - $this->connected = false; - $this->storage = array(); - } + private $connected = false; + private $storage = array(); /** * Set a Memcached option diff --git a/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php b/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php index ca2980edde466..4a89e2db88728 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php +++ b/src/Symfony/Component/HttpKernel/Tests/Profiler/Mock/RedisMock.php @@ -18,15 +18,8 @@ */ class RedisMock { - - private $connected; - private $storage; - - public function __construct() - { - $this->connected = false; - $this->storage = array(); - } + private $connected = false; + private $storage = array(); /** * Add a server to connection pool diff --git a/src/Symfony/Component/Process/ProcessBuilder.php b/src/Symfony/Component/Process/ProcessBuilder.php index 670af08f76ff6..b6168feb62d0e 100644 --- a/src/Symfony/Component/Process/ProcessBuilder.php +++ b/src/Symfony/Component/Process/ProcessBuilder.php @@ -23,21 +23,16 @@ class ProcessBuilder { private $arguments; private $cwd; - private $env; + private $env = array(); private $stdin; - private $timeout; - private $options; - private $inheritEnv; + private $timeout = 60; + private $options = array(); + private $inheritEnv = true; private $prefix = array(); public function __construct(array $arguments = array()) { $this->arguments = $arguments; - - $this->timeout = 60; - $this->options = array(); - $this->env = array(); - $this->inheritEnv = true; } public static function create(array $arguments = array()) diff --git a/src/Symfony/Component/Routing/Annotation/Route.php b/src/Symfony/Component/Routing/Annotation/Route.php index f6100731dd51a..ebda0971c5fda 100644 --- a/src/Symfony/Component/Routing/Annotation/Route.php +++ b/src/Symfony/Component/Routing/Annotation/Route.php @@ -22,12 +22,12 @@ class Route { private $path; private $name; - private $requirements; - private $options; - private $defaults; + private $requirements = array(); + private $options = array(); + private $defaults = array(); private $host; - private $methods; - private $schemes; + private $methods = array(); + private $schemes = array(); private $condition; /** @@ -39,12 +39,6 @@ class Route */ public function __construct(array $data) { - $this->requirements = array(); - $this->options = array(); - $this->defaults = array(); - $this->methods = array(); - $this->schemes = array(); - if (isset($data['value'])) { $data['path'] = $data['value']; unset($data['value']); diff --git a/src/Symfony/Component/Routing/Router.php b/src/Symfony/Component/Routing/Router.php index e9671922ba3be..50ed79532d298 100644 --- a/src/Symfony/Component/Routing/Router.php +++ b/src/Symfony/Component/Routing/Router.php @@ -82,7 +82,7 @@ public function __construct(LoaderInterface $loader, $resource, array $options = $this->loader = $loader; $this->resource = $resource; $this->logger = $logger; - $this->context = null === $context ? new RequestContext() : $context; + $this->context = $context ?: new RequestContext(); $this->setOptions($options); } diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php index 7b4565c40375d..de01a75d0b1b1 100644 --- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php +++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/DumperPrefixCollectionTest.php @@ -20,7 +20,7 @@ class DumperPrefixCollectionTest extends \PHPUnit_Framework_TestCase { public function testAddPrefixRoute() { - $coll = new DumperPrefixCollection; + $coll = new DumperPrefixCollection(); $coll->setPrefix(''); $route = new DumperRoute('bar', new Route('/foo/bar')); @@ -66,7 +66,7 @@ public function testAddPrefixRoute() public function testMergeSlashNodes() { - $coll = new DumperPrefixCollection; + $coll = new DumperPrefixCollection(); $coll->setPrefix(''); $route = new DumperRoute('bar', new Route('/foo/bar')); diff --git a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php index 822a16017c59f..58c00d35947a0 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/AclProvider.php @@ -40,8 +40,8 @@ class AclProvider implements AclProviderInterface protected $cache; protected $connection; - protected $loadedAces; - protected $loadedAcls; + protected $loadedAces = array(); + protected $loadedAcls = array(); protected $options; private $permissionGrantingStrategy; @@ -57,8 +57,6 @@ public function __construct(Connection $connection, PermissionGrantingStrategyIn { $this->cache = $cache; $this->connection = $connection; - $this->loadedAces = array(); - $this->loadedAcls = array(); $this->options = $options; $this->permissionGrantingStrategy = $permissionGrantingStrategy; } diff --git a/src/Symfony/Component/Security/Acl/Domain/Acl.php b/src/Symfony/Component/Security/Acl/Domain/Acl.php index 4665c0e18dbe2..dd3e8d4f51691 100644 --- a/src/Symfony/Component/Security/Acl/Domain/Acl.php +++ b/src/Symfony/Component/Security/Acl/Domain/Acl.php @@ -37,14 +37,14 @@ class Acl implements AuditableAclInterface, NotifyPropertyChanged private $parentAcl; private $permissionGrantingStrategy; private $objectIdentity; - private $classAces; - private $classFieldAces; - private $objectAces; - private $objectFieldAces; + private $classAces = array(); + private $classFieldAces = array(); + private $objectAces = array(); + private $objectFieldAces = array(); private $id; private $loadedSids; private $entriesInheriting; - private $listeners; + private $listeners = array(); /** * Constructor @@ -62,12 +62,6 @@ public function __construct($id, ObjectIdentityInterface $objectIdentity, Permis $this->permissionGrantingStrategy = $permissionGrantingStrategy; $this->loadedSids = $loadedSids; $this->entriesInheriting = $entriesInheriting; - $this->parentAcl = null; - $this->classAces = array(); - $this->classFieldAces = array(); - $this->objectAces = array(); - $this->objectFieldAces = array(); - $this->listeners = array(); } /** diff --git a/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php b/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php index 9ec6538871e8d..d9db824c33abb 100644 --- a/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php +++ b/src/Symfony/Component/Security/Acl/Tests/Permission/MaskBuilderTest.php @@ -76,7 +76,7 @@ public function testAddAndRemove() public function testGetPattern() { - $builder = new MaskBuilder; + $builder = new MaskBuilder(); $this->assertEquals(MaskBuilder::ALL_OFF, $builder->getPattern()); $builder->add('view'); diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php index c532532c7d5de..e62f73c33cb37 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php +++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php @@ -26,9 +26,9 @@ abstract class AbstractToken implements TokenInterface { private $user; - private $roles; - private $authenticated; - private $attributes; + private $roles = array(); + private $authenticated = false; + private $attributes = array(); /** * Constructor. @@ -39,10 +39,6 @@ abstract class AbstractToken implements TokenInterface */ public function __construct(array $roles = array()) { - $this->authenticated = false; - $this->attributes = array(); - - $this->roles = array(); foreach ($roles as $role) { if (is_string($role)) { $role = new Role($role); diff --git a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php index ea85e776a84c2..a5e0222b32b61 100644 --- a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php @@ -139,7 +139,7 @@ private function fail(GetResponseEvent $event, Request $request, AuthenticationE class DigestData { - private $elements; + private $elements = array(); private $header; private $nonceExpiryTime; @@ -147,7 +147,6 @@ public function __construct($header) { $this->header = $header; preg_match_all('/(\w+)=("((?:[^"\\\\]|\\\\.)+)"|([^\s,$]+))/', $header, $matches, PREG_SET_ORDER); - $this->elements = array(); foreach ($matches as $match) { if (isset($match[1]) && isset($match[3])) { $this->elements[$match[1]] = isset($match[4]) ? $match[4] : $match[3]; diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php index 3c4b10d6c577f..927b77115b7b4 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/AbstractRememberMeServicesTest.php @@ -43,7 +43,7 @@ public function testAutoLoginReturnsNullWhenNoCookie() public function testAutoLoginThrowsExceptionWhenImplementationDoesNotReturnUserInterface() { $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null)); - $request = new Request; + $request = new Request(); $request->cookies->set('foo', 'foo'); $service @@ -106,8 +106,8 @@ public function testLoginFail() public function testLoginSuccessIsNotProcessedWhenTokenDoesNotContainUserInterfaceImplementation() { $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null)); - $request = new Request; - $response = new Response; + $request = new Request(); + $response = new Response(); $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $token @@ -129,8 +129,8 @@ public function testLoginSuccessIsNotProcessedWhenTokenDoesNotContainUserInterfa public function testLoginSuccessIsNotProcessedWhenRememberMeIsNotRequested() { $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => false, 'remember_me_parameter' => 'foo', 'path' => null, 'domain' => null)); - $request = new Request; - $response = new Response; + $request = new Request(); + $response = new Response(); $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $token @@ -153,8 +153,8 @@ public function testLoginSuccessIsNotProcessedWhenRememberMeIsNotRequested() public function testLoginSuccessWhenRememberMeAlwaysIsTrue() { $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null)); - $request = new Request; - $response = new Response; + $request = new Request(); + $response = new Response(); $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $token @@ -179,9 +179,9 @@ public function testLoginSuccessWhenRememberMeParameterWithPathIsPositive($value { $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => false, 'remember_me_parameter' => 'foo[bar]', 'path' => null, 'domain' => null)); - $request = new Request; + $request = new Request(); $request->request->set('foo', array('bar' => $value)); - $response = new Response; + $response = new Response(); $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $token @@ -206,9 +206,9 @@ public function testLoginSuccessWhenRememberMeParameterIsPositive($value) { $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => false, 'remember_me_parameter' => 'foo', 'path' => null, 'domain' => null)); - $request = new Request; + $request = new Request(); $request->request->set('foo', $value); - $response = new Response; + $response = new Response(); $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $token diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php index 91188a470f53a..098f5b6e61ed7 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/PersistentTokenBasedRememberMeServicesTest.php @@ -36,7 +36,7 @@ public function testAutoLoginReturnsNullWhenNoCookie() public function testAutoLoginThrowsExceptionOnInvalidCookie() { $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => false, 'remember_me_parameter' => 'foo')); - $request = new Request; + $request = new Request(); $request->request->set('foo', 'true'); $request->cookies->set('foo', 'foo'); @@ -47,7 +47,7 @@ public function testAutoLoginThrowsExceptionOnInvalidCookie() public function testAutoLoginThrowsExceptionOnNonExistentToken() { $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => false, 'remember_me_parameter' => 'foo')); - $request = new Request; + $request = new Request(); $request->request->set('foo', 'true'); $request->cookies->set('foo', $this->encodeCookie(array( $series = 'fooseries', @@ -70,7 +70,7 @@ public function testAutoLoginReturnsNullOnNonExistentUser() { $userProvider = $this->getProvider(); $service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true, 'lifetime' => 3600, 'secure' => false, 'httponly' => false)); - $request = new Request; + $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); @@ -95,7 +95,7 @@ public function testAutoLoginThrowsExceptionOnStolenCookieAndRemovesItFromThePer { $userProvider = $this->getProvider(); $service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true)); - $request = new Request; + $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); @@ -125,7 +125,7 @@ public function testAutoLoginThrowsExceptionOnStolenCookieAndRemovesItFromThePer public function testAutoLoginDoesNotAcceptAnExpiredCookie() { $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true, 'lifetime' => 3600)); - $request = new Request; + $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); @@ -159,7 +159,7 @@ public function testAutoLogin() ; $service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'secure' => false, 'httponly' => false, 'always_remember_me' => true, 'lifetime' => 3600)); - $request = new Request; + $request = new Request(); $request->cookies->set('foo', $this->encodeCookie(array('fooseries', 'foovalue'))); $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); @@ -207,8 +207,8 @@ public function testLogout() public function testLogoutSimplyIgnoresNonSetRequestCookie() { $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null)); - $request = new Request; - $response = new Response; + $request = new Request(); + $response = new Response(); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); @@ -229,9 +229,9 @@ public function testLogoutSimplyIgnoresNonSetRequestCookie() public function testLogoutSimplyIgnoresInvalidCookie() { $service = $this->getService(null, array('name' => 'foo', 'path' => null, 'domain' => null)); - $request = new Request; + $request = new Request(); $request->cookies->set('foo', 'somefoovalue'); - $response = new Response; + $response = new Response(); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $tokenProvider = $this->getMock('Symfony\Component\Security\Core\Authentication\RememberMe\TokenProviderInterface'); @@ -259,8 +259,8 @@ public function testLoginFail() public function testLoginSuccessSetsCookieWhenLoggedInWithNonRememberMeTokenInterfaceImplementation() { $service = $this->getService(null, array('name' => 'foo', 'domain' => 'myfoodomain.foo', 'path' => '/foo/path', 'secure' => true, 'httponly' => true, 'lifetime' => 3600, 'always_remember_me' => true)); - $request = new Request; - $response = new Response; + $request = new Request(); + $response = new Response(); $account = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); $account diff --git a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php index d6025caf74c72..95c942e006813 100644 --- a/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php +++ b/src/Symfony/Component/Security/Http/Tests/RememberMe/TokenBasedRememberMeServicesTest.php @@ -44,7 +44,7 @@ public function testAutoLoginThrowsExceptionOnNonExistentUser() { $userProvider = $this->getProvider(); $service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true, 'lifetime' => 3600)); - $request = new Request; + $request = new Request(); $request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time()+3600, 'foopass')); $userProvider @@ -61,7 +61,7 @@ public function testAutoLoginDoesNotAcceptCookieWithInvalidHash() { $userProvider = $this->getProvider(); $service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true, 'lifetime' => 3600)); - $request = new Request; + $request = new Request(); $request->cookies->set('foo', base64_encode('class:'.base64_encode('foouser').':123456789:fooHash')); $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); @@ -86,7 +86,7 @@ public function testAutoLoginDoesNotAcceptAnExpiredCookie() { $userProvider = $this->getProvider(); $service = $this->getService($userProvider, array('name' => 'foo', 'path' => null, 'domain' => null, 'always_remember_me' => true, 'lifetime' => 3600)); - $request = new Request; + $request = new Request(); $request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time() - 1, 'foopass')); $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); @@ -130,7 +130,7 @@ public function testAutoLogin() ; $service = $this->getService($userProvider, array('name' => 'foo', 'always_remember_me' => true, 'lifetime' => 3600)); - $request = new Request; + $request = new Request(); $request->cookies->set('foo', $this->getCookie('fooclass', 'foouser', time()+3600, 'foopass')); $returnedToken = $service->autoLogin($request); @@ -172,8 +172,8 @@ public function testLoginFail() public function testLoginSuccessIgnoresTokensWhichDoNotContainAnUserInterfaceImplementation() { $service = $this->getService(null, array('name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null)); - $request = new Request; - $response = new Response; + $request = new Request(); + $response = new Response(); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $token ->expects($this->once()) @@ -193,8 +193,8 @@ public function testLoginSuccessIgnoresTokensWhichDoNotContainAnUserInterfaceImp public function testLoginSuccess() { $service = $this->getService(null, array('name' => 'foo', 'domain' => 'myfoodomain.foo', 'path' => '/foo/path', 'secure' => true, 'httponly' => true, 'lifetime' => 3600, 'always_remember_me' => true)); - $request = new Request; - $response = new Response; + $request = new Request(); + $response = new Response(); $token = $this->getMock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface'); $user = $this->getMock('Symfony\Component\Security\Core\User\UserInterface'); diff --git a/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php b/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php index 02b179bc91a66..95dae7c8c6674 100644 --- a/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php +++ b/src/Symfony/Component/Serializer/Encoder/JsonEncoder.php @@ -32,8 +32,8 @@ class JsonEncoder implements EncoderInterface, DecoderInterface public function __construct(JsonEncode $encodingImpl = null, JsonDecode $decodingImpl = null) { - $this->encodingImpl = null === $encodingImpl ? new JsonEncode() : $encodingImpl; - $this->decodingImpl = null === $decodingImpl ? new JsonDecode(true) : $decodingImpl; + $this->encodingImpl = $encodingImpl ?: new JsonEncode(); + $this->decodingImpl = $decodingImpl ?: new JsonDecode(true); } /** diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php index b5ec1a2352235..00714f23ba2a9 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/JsonEncoderTest.php @@ -19,7 +19,7 @@ class JsonEncoderTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - $this->encoder = new JsonEncoder; + $this->encoder = new JsonEncoder(); $this->serializer = new Serializer(array(new CustomNormalizer()), array('json' => new JsonEncoder())); } diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php index 5b7c29e84bda5..9668654284c9c 100644 --- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php +++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php @@ -24,14 +24,14 @@ class XmlEncoderTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->encoder = new XmlEncoder; + $this->encoder = new XmlEncoder(); $serializer = new Serializer(array(new CustomNormalizer()), array('xml' => new XmlEncoder())); $this->encoder->setSerializer($serializer); } public function testEncodeScalar() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->xmlFoo = "foo"; $expected = ''."\n". @@ -42,7 +42,7 @@ public function testEncodeScalar() public function testSetRootNodeName() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->xmlFoo = "foo"; $this->encoder->setRootNodeName('test'); @@ -63,7 +63,7 @@ public function testDocTypeIsNotAllowed() public function testAttributes() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->xmlFoo = array( 'foo-bar' => array( '@id' => 1, @@ -92,7 +92,7 @@ public function testAttributes() public function testElementNameValid() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->xmlFoo = array( 'foo-bar' => 'a', 'foo_bar' => 'a', @@ -206,7 +206,7 @@ public function testEncode() public function testEncodeSerializerXmlRootNodeNameOption() { $options = array('xml_root_node_name' => 'test'); - $this->encoder = new XmlEncoder; + $this->encoder = new XmlEncoder(); $serializer = new Serializer(array(), array('xml' => new XmlEncoder())); $this->encoder->setSerializer($serializer); @@ -289,7 +289,7 @@ public function testDecodeArray() public function testDecodeWithoutItemHash() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->xmlFoo = array( 'foo-bar' => array( '@key' => "value", @@ -362,7 +362,7 @@ protected function getXmlSource() protected function getObject() { - $obj = new Dummy; + $obj = new Dummy(); $obj->foo = 'foo'; $obj->bar = array('a', 'b'); $obj->baz = array('key' => 'val', 'key2' => 'val', 'A B' => 'bar', 'item' => array(array('title' => 'title1'), array('title' => 'title2')), 'Barry' => array('FooBar' => array('Baz' => 'Ed', '@id' => 1))); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php index 7b4b4ae28d85f..eef163442edac 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/CustomNormalizerTest.php @@ -19,13 +19,13 @@ class CustomNormalizerTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - $this->normalizer = new CustomNormalizer; - $this->normalizer->setSerializer(new Serializer); + $this->normalizer = new CustomNormalizer(); + $this->normalizer->setSerializer(new Serializer()); } public function testSerialize() { - $obj = new ScalarDummy; + $obj = new ScalarDummy(); $obj->foo = 'foo'; $obj->xmlFoo = 'xml'; $this->assertEquals('foo', $this->normalizer->normalize($obj, 'json')); @@ -34,18 +34,18 @@ public function testSerialize() public function testDeserialize() { - $obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy), 'xml'); + $obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy()), 'xml'); $this->assertEquals('foo', $obj->xmlFoo); $this->assertNull($obj->foo); - $obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy), 'json'); + $obj = $this->normalizer->denormalize('foo', get_class(new ScalarDummy()), 'json'); $this->assertEquals('foo', $obj->foo); $this->assertNull($obj->xmlFoo); } public function testSupportsNormalization() { - $this->assertTrue($this->normalizer->supportsNormalization(new ScalarDummy)); + $this->assertTrue($this->normalizer->supportsNormalization(new ScalarDummy())); $this->assertFalse($this->normalizer->supportsNormalization(new \stdClass)); } diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php index 42846166e453b..f3bf9694d206c 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php @@ -17,13 +17,13 @@ class GetSetMethodNormalizerTest extends \PHPUnit_Framework_TestCase { protected function setUp() { - $this->normalizer = new GetSetMethodNormalizer; + $this->normalizer = new GetSetMethodNormalizer(); $this->normalizer->setSerializer($this->getMock('Symfony\Component\Serializer\Serializer')); } public function testNormalize() { - $obj = new GetSetDummy; + $obj = new GetSetDummy(); $obj->setFoo('foo'); $obj->setBar('bar'); $obj->setCamelCase('camelcase'); @@ -118,7 +118,7 @@ public function testIgnoredAttributes() { $this->normalizer->setIgnoredAttributes(array('foo', 'bar', 'camelCase')); - $obj = new GetSetDummy; + $obj = new GetSetDummy(); $obj->setFoo('foo'); $obj->setBar('bar'); diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php index 3c189461f28f1..106bcff7adb59 100644 --- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php +++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php @@ -34,14 +34,14 @@ public function testNormalizeNoMatch() public function testNormalizeTraversable() { $this->serializer = new Serializer(array(), array('json' => new JsonEncoder())); - $result = $this->serializer->serialize(new TraversableDummy, 'json'); + $result = $this->serializer->serialize(new TraversableDummy(), 'json'); $this->assertEquals('{"foo":"foo","bar":"bar"}', $result); } public function testNormalizeGivesPriorityToInterfaceOverTraversable() { - $this->serializer = new Serializer(array(new CustomNormalizer), array('json' => new JsonEncoder())); - $result = $this->serializer->serialize(new NormalizableTraversableDummy, 'json'); + $this->serializer = new Serializer(array(new CustomNormalizer()), array('json' => new JsonEncoder())); + $result = $this->serializer->serialize(new NormalizableTraversableDummy(), 'json'); $this->assertEquals('{"foo":"normalizedFoo","bar":"normalizedBar"}', $result); } diff --git a/src/Symfony/Component/Stopwatch/StopwatchEvent.php b/src/Symfony/Component/Stopwatch/StopwatchEvent.php index 7adfdf0bb84b0..41d7279e35824 100644 --- a/src/Symfony/Component/Stopwatch/StopwatchEvent.php +++ b/src/Symfony/Component/Stopwatch/StopwatchEvent.php @@ -21,7 +21,7 @@ class StopwatchEvent /** * @var StopwatchPeriod[] */ - private $periods; + private $periods = array(); /** * @var float @@ -36,13 +36,13 @@ class StopwatchEvent /** * @var float[] */ - private $started; + private $started = array(); /** * Constructor. * - * @param float $origin The origin time in milliseconds - * @param string $category The event category + * @param float $origin The origin time in milliseconds + * @param string|null $category The event category or null to use the default * * @throws \InvalidArgumentException When the raw time is not valid */ @@ -50,8 +50,6 @@ public function __construct($origin, $category = null) { $this->origin = $this->formatTime($origin); $this->category = is_string($category) ? $category : 'default'; - $this->started = array(); - $this->periods = array(); } /** @@ -67,7 +65,7 @@ public function getCategory() /** * Gets the origin. * - * @return integer The origin in milliseconds + * @return float The origin in milliseconds */ public function getOrigin() { @@ -178,7 +176,7 @@ public function getDuration() $total += $period->getDuration(); } - return $this->formatTime($total); + return $total; } /** diff --git a/src/Symfony/Component/Stopwatch/StopwatchPeriod.php b/src/Symfony/Component/Stopwatch/StopwatchPeriod.php index 57393f4742be0..f757a016a93b4 100644 --- a/src/Symfony/Component/Stopwatch/StopwatchPeriod.php +++ b/src/Symfony/Component/Stopwatch/StopwatchPeriod.php @@ -23,10 +23,10 @@ class StopwatchPeriod private $memory; /** - * Constructor + * Constructor. * - * @param integer $start The relative time of the start of the period - * @param integer $end The relative time of the end of the period + * @param integer $start The relative time of the start of the period (in milliseconds) + * @param integer $end The relative time of the end of the period (in milliseconds) */ public function __construct($start, $end) { diff --git a/src/Symfony/Component/Templating/DelegatingEngine.php b/src/Symfony/Component/Templating/DelegatingEngine.php index ce7e833b55e2c..c08540bf36c66 100644 --- a/src/Symfony/Component/Templating/DelegatingEngine.php +++ b/src/Symfony/Component/Templating/DelegatingEngine.php @@ -23,7 +23,7 @@ class DelegatingEngine implements EngineInterface, StreamingEngineInterface /** * @var EngineInterface[] */ - protected $engines; + protected $engines = array(); /** * Constructor. @@ -34,7 +34,6 @@ class DelegatingEngine implements EngineInterface, StreamingEngineInterface */ public function __construct(array $engines = array()) { - $this->engines = array(); foreach ($engines as $engine) { $this->addEngine($engine); } diff --git a/src/Symfony/Component/Templating/Helper/CoreAssetsHelper.php b/src/Symfony/Component/Templating/Helper/CoreAssetsHelper.php index a0a643a41b5c3..73f1455622821 100644 --- a/src/Symfony/Component/Templating/Helper/CoreAssetsHelper.php +++ b/src/Symfony/Component/Templating/Helper/CoreAssetsHelper.php @@ -28,7 +28,7 @@ class CoreAssetsHelper extends Helper implements PackageInterface { protected $defaultPackage; - protected $namedPackages; + protected $namedPackages = array(); /** * Constructor. @@ -39,7 +39,6 @@ class CoreAssetsHelper extends Helper implements PackageInterface public function __construct(PackageInterface $defaultPackage, array $namedPackages = array()) { $this->defaultPackage = $defaultPackage; - $this->namedPackages = array(); foreach ($namedPackages as $name => $package) { $this->addPackage($name, $package); diff --git a/src/Symfony/Component/Templating/Loader/ChainLoader.php b/src/Symfony/Component/Templating/Loader/ChainLoader.php index 2009856e79b18..bcb250b08f5e2 100644 --- a/src/Symfony/Component/Templating/Loader/ChainLoader.php +++ b/src/Symfony/Component/Templating/Loader/ChainLoader.php @@ -21,7 +21,7 @@ */ class ChainLoader extends Loader { - protected $loaders; + protected $loaders = array(); /** * Constructor. @@ -30,7 +30,6 @@ class ChainLoader extends Loader */ public function __construct(array $loaders = array()) { - $this->loaders = array(); foreach ($loaders as $loader) { $this->addLoader($loader); } diff --git a/src/Symfony/Component/Templating/PhpEngine.php b/src/Symfony/Component/Templating/PhpEngine.php index 324ebc7c798f9..9ba1ae92dac5e 100644 --- a/src/Symfony/Component/Templating/PhpEngine.php +++ b/src/Symfony/Component/Templating/PhpEngine.php @@ -32,14 +32,14 @@ class PhpEngine implements EngineInterface, \ArrayAccess { protected $loader; protected $current; - protected $helpers; - protected $parents; - protected $stack; - protected $charset; - protected $cache; - protected $escapers; - protected static $escaperCache; - protected $globals; + protected $helpers = array(); + protected $parents = array(); + protected $stack = array(); + protected $charset = 'UTF-8'; + protected $cache = array(); + protected $escapers = array(); + protected static $escaperCache = array(); + protected $globals = array(); protected $parser; private $evalTemplate; @@ -56,13 +56,8 @@ public function __construct(TemplateNameParserInterface $parser, LoaderInterface { $this->parser = $parser; $this->loader = $loader; - $this->parents = array(); - $this->stack = array(); - $this->charset = 'UTF-8'; - $this->cache = array(); - $this->globals = array(); - $this->setHelpers($helpers); + $this->addHelpers($helpers); $this->initializeEscapers(); foreach ($this->escapers as $context => $escaper) { diff --git a/src/Symfony/Component/Validator/Constraints/Collection.php b/src/Symfony/Component/Validator/Constraints/Collection.php index d60f0c273d13b..9b641dad240bb 100644 --- a/src/Symfony/Component/Validator/Constraints/Collection.php +++ b/src/Symfony/Component/Validator/Constraints/Collection.php @@ -25,7 +25,7 @@ */ class Collection extends Constraint { - public $fields; + public $fields = array(); public $allowExtraFields = false; public $allowMissingFields = false; public $extraFieldsMessage = 'This field was not expected.'; diff --git a/src/Symfony/Component/Validator/Tests/ConstraintTest.php b/src/Symfony/Component/Validator/Tests/ConstraintTest.php index 6ba59caef0b66..015a6dab665e2 100644 --- a/src/Symfony/Component/Validator/Tests/ConstraintTest.php +++ b/src/Symfony/Component/Validator/Tests/ConstraintTest.php @@ -143,14 +143,14 @@ public function testCanCreateConstraintWithNoDefaultOptionAndEmptyArray() public function testGetTargetsCanBeString() { - $constraint = new ClassConstraint; + $constraint = new ClassConstraint(); $this->assertEquals('class', $constraint->getTargets()); } public function testGetTargetsCanBeArray() { - $constraint = new ConstraintA; + $constraint = new ConstraintA(); $this->assertEquals(array('property', 'class'), $constraint->getTargets()); }