From b49fa129bdb3c0aa970a006b16dd1ca63a9d7ebd Mon Sep 17 00:00:00 2001 From: thewilkybarkid Date: Sat, 13 Dec 2014 16:43:22 +0000 Subject: [PATCH 1/9] Make the container considered non-fresh if the environment parameters are changed --- .../Config/EnvParametersResource.php | 95 ++++++++++++++++ src/Symfony/Component/HttpKernel/Kernel.php | 2 + .../Config/EnvParametersResourceTest.php | 106 ++++++++++++++++++ .../Component/HttpKernel/Tests/KernelTest.php | 30 +++++ 4 files changed, 233 insertions(+) create mode 100644 src/Symfony/Component/HttpKernel/Config/EnvParametersResource.php create mode 100644 src/Symfony/Component/HttpKernel/Tests/Config/EnvParametersResourceTest.php diff --git a/src/Symfony/Component/HttpKernel/Config/EnvParametersResource.php b/src/Symfony/Component/HttpKernel/Config/EnvParametersResource.php new file mode 100644 index 0000000000..5f54450137 --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Config/EnvParametersResource.php @@ -0,0 +1,95 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Config; + +use Symfony\Component\Config\Resource\ResourceInterface; + +/** + * EnvParametersResource represents resources stored in prefixed environment variables. + * + * @author Chris Wilkinson + */ +class EnvParametersResource implements ResourceInterface, \Serializable +{ + /** + * @var string + */ + private $prefix; + + /** + * @var string + */ + private $variables; + + /** + * Constructor. + * + * @param string $prefix + */ + public function __construct($prefix) + { + $this->prefix = $prefix; + $this->variables = $this->findVariables(); + } + + /** + * {@inheritdoc} + */ + public function __toString() + { + return serialize($this->getResource()); + } + + /** + * {@inheritdoc} + */ + public function getResource() + { + return array('prefix' => $this->prefix, 'variables' => $this->variables); + } + + /** + * {@inheritdoc} + */ + public function isFresh($timestamp) + { + return $this->findVariables() === $this->variables; + } + + public function serialize() + { + return serialize(array('prefix' => $this->prefix, 'variables' => $this->variables)); + } + + public function unserialize($serialized) + { + $unserialized = unserialize($serialized); + + $this->prefix = $unserialized['prefix']; + $this->variables = $unserialized['variables']; + } + + private function findVariables() + { + $variables = array(); + + foreach ($_SERVER as $key => $value) { + if (0 === strpos($key, $this->prefix)) { + $variables[$key] = $value; + } + } + + ksort($variables); + + return $variables; + } +} diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index a0e6b1a860..968f2a1599 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -25,6 +25,7 @@ use Symfony\Component\DependencyInjection\Loader\ClosureLoader; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Bundle\BundleInterface; +use Symfony\Component\HttpKernel\Config\EnvParametersResource; use Symfony\Component\HttpKernel\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass; @@ -647,6 +648,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface } $container->addCompilerPass(new AddClassesToCachePass($this)); + $container->addResource(new EnvParametersResource('SYMFONY__')); return $container; } diff --git a/src/Symfony/Component/HttpKernel/Tests/Config/EnvParametersResourceTest.php b/src/Symfony/Component/HttpKernel/Tests/Config/EnvParametersResourceTest.php new file mode 100644 index 0000000000..ee5ecce3ce --- /dev/null +++ b/src/Symfony/Component/HttpKernel/Tests/Config/EnvParametersResourceTest.php @@ -0,0 +1,106 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\HttpKernel\Tests\Config; + +use Symfony\Component\HttpKernel\Config\EnvParametersResource; + +class EnvParametersResourceTest extends \PHPUnit_Framework_TestCase +{ + protected $prefix = '__DUMMY_'; + protected $initialEnv; + protected $resource; + + protected function setUp() + { + $this->initialEnv = array( + $this->prefix.'1' => 'foo', + $this->prefix.'2' => 'bar', + ); + + foreach ($this->initialEnv as $key => $value) { + $_SERVER[$key] = $value; + } + + $this->resource = new EnvParametersResource($this->prefix); + } + + protected function tearDown() + { + foreach ($_SERVER as $key => $value) { + if (0 === strpos($key, $this->prefix)) { + unset($_SERVER[$key]); + } + } + } + + public function testGetResource() + { + $this->assertSame( + array('prefix' => $this->prefix, 'variables' => $this->initialEnv), + $this->resource->getResource(), + '->getResource() returns the resource' + ); + } + + public function testToString() + { + $this->assertSame( + serialize(array('prefix' => $this->prefix, 'variables' => $this->initialEnv)), + (string) $this->resource + ); + } + + public function testIsFreshNotChanged() + { + $this->assertTrue( + $this->resource->isFresh(time()), + '->isFresh() returns true if the variables have not changed' + ); + } + + public function testIsFreshValueChanged() + { + reset($this->initialEnv); + $_SERVER[key($this->initialEnv)] = 'baz'; + + $this->assertFalse( + $this->resource->isFresh(time()), + '->isFresh() returns false if a variable has been changed' + ); + } + + public function testIsFreshValueRemoved() + { + reset($this->initialEnv); + unset($_SERVER[key($this->initialEnv)]); + + $this->assertFalse( + $this->resource->isFresh(time()), + '->isFresh() returns false if a variable has been removed' + ); + } + + public function testIsFreshValueAdded() + { + $_SERVER[$this->prefix.'3'] = 'foo'; + + $this->assertFalse( + $this->resource->isFresh(time()), + '->isFresh() returns false if a variable has been added' + ); + } + + public function testSerializeUnserialize() + { + $this->assertEquals($this->resource, unserialize(serialize($this->resource))); + } +} diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index b68e37e398..468d30cec8 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\HttpKernel\Tests; +use Symfony\Component\HttpKernel\Config\EnvParametersResource; use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\HttpKernelInterface; @@ -154,6 +155,35 @@ class KernelTest extends \PHPUnit_Framework_TestCase ->method('doLoadClassCache'); } + public function testEnvParametersResourceIsAdded() + { + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') + ->disableOriginalConstructor() + ->setMethods(array('getContainerBuilder', 'prepareContainer', 'getCacheDir', 'getLogDir')) + ->getMock(); + $kernel->expects($this->any()) + ->method('getContainerBuilder') + ->will($this->returnValue($container)); + $kernel->expects($this->any()) + ->method('prepareContainer') + ->will($this->returnValue(null)); + $kernel->expects($this->any()) + ->method('getCacheDir') + ->will($this->returnValue(sys_get_temp_dir())); + $kernel->expects($this->any()) + ->method('getLogDir') + ->will($this->returnValue(sys_get_temp_dir())); + $container->expects($this->once()) + ->method('addResource') + ->with(new EnvParametersResource('SYMFONY__')); + + $reflection = new \ReflectionClass(get_class($kernel)); + $method = $reflection->getMethod('buildContainer'); + $method->setAccessible(true); + $method->invoke($kernel); + } + public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce() { $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest') From e6afff4f08240fa4cf0c3e9e8915cd9790cd33ae Mon Sep 17 00:00:00 2001 From: nacho Date: Wed, 7 Jan 2015 23:10:19 +0100 Subject: [PATCH 2/9] [Console] fixed #10531 --- src/Symfony/Component/Console/Application.php | 28 +++++++++++++++++-- .../Console/Tests/ApplicationTest.php | 10 +++++++ .../Fixtures/FooSubnamespaced1Command.php | 26 +++++++++++++++++ .../Fixtures/FooSubnamespaced2Command.php | 26 +++++++++++++++++ 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php create mode 100644 src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 359ac69280..44b29add8b 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -469,10 +469,10 @@ class Application { $namespaces = array(); foreach ($this->commands as $command) { - $namespaces[] = $this->extractNamespace($command->getName()); + $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName())); foreach ($command->getAliases() as $alias) { - $namespaces[] = $this->extractNamespace($alias); + $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias)); } } @@ -1169,4 +1169,28 @@ class Application return $lines; } + + /** + * Returns all namespaces of the command name. + * + * @param string $name The full name of the command + * + * @return array The namespaces of the command + */ + private function extractAllNamespaces($name) + { + // -1 as third argument is needed to skip the command short name when exploding + $parts = explode(':', $name, -1); + $namespaces = array(); + + foreach ($parts as $part) { + if (count($namespaces)) { + $namespaces[] = end($namespaces).':'.$part; + } else { + $namespaces[] = $part; + } + } + + return $namespaces; + } } diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index 8f63a33b26..6180b6122d 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -40,6 +40,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase require_once self::$fixturesPath.'/Foo2Command.php'; require_once self::$fixturesPath.'/Foo3Command.php'; require_once self::$fixturesPath.'/Foo4Command.php'; + require_once self::$fixturesPath.'/FooSubnamespaced1Command.php'; + require_once self::$fixturesPath.'/FooSubnamespaced2Command.php'; } protected function normalizeLineBreaks($text) @@ -186,6 +188,14 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns the given namespace if it exists'); } + public function testFindNamespaceWithSubnamespaces() + { + $application = new Application(); + $application->add(new \FooSubnamespaced1Command()); + $application->add(new \FooSubnamespaced2Command()); + $this->assertEquals('foo', $application->findNamespace('foo'), '->findNamespace() returns commands even if the commands are only contained in subnamespaces'); + } + /** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The namespace "f" is ambiguous (foo, foo1). diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php new file mode 100644 index 0000000000..fc50c72bfc --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced1Command.php @@ -0,0 +1,26 @@ +setName('foo:bar:baz') + ->setDescription('The foo:bar:baz command') + ->setAliases(array('foobarbaz')) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->input = $input; + $this->output = $output; + } +} diff --git a/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php new file mode 100644 index 0000000000..1cf31ff110 --- /dev/null +++ b/src/Symfony/Component/Console/Tests/Fixtures/FooSubnamespaced2Command.php @@ -0,0 +1,26 @@ +setName('foo:go:bret') + ->setDescription('The foo:bar:go command') + ->setAliases(array('foobargo')) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $this->input = $input; + $this->output = $output; + } +} From 58a742608581e2323df51a2691afe3e0749f1924 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Sat, 10 Jan 2015 08:51:00 +0000 Subject: [PATCH 3/9] [Yaml] fixed parse shortcut Key after unindented collection. --- src/Symfony/Component/Yaml/Parser.php | 14 +++++++++---- .../Tests/Fixtures/unindentedCollections.yml | 20 +++++++++++++++++++ .../Component/Yaml/Tests/ParserTest.php | 16 +++++++++++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 01c6687f4a..2771f51fd2 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -96,7 +96,6 @@ class Parser $data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport); } else { if (isset($values['leadspaces']) - && ' ' == $values['leadspaces'] && preg_match('#^(?P'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P.+?))?\s*$#u', $values['value'], $matches) ) { // this is a compact notation element, add to next block and parse @@ -106,7 +105,7 @@ class Parser $block = $values['value']; if ($this->isNextLineIndented()) { - $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + 2); + $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + strlen($values['leadspaces']) + 1); } $data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport); @@ -313,7 +312,14 @@ class Parser $newIndent = $indentation; } - $data = array(substr($this->currentLine, $newIndent)); + $data = array(); + if ($this->getCurrentLineIndentation() >= $newIndent) { + $data[] = substr($this->currentLine, $newIndent); + } else { + $this->moveToPreviousLine(); + + return; + } if ($inSequence && $oldLineIndentation === $newIndent && '-' === $data[0][0]) { // the previous line contained a dash but no item content, this line is a sequence item with the same indentation @@ -336,7 +342,7 @@ class Parser $removeComments = !preg_match($removeCommentsPattern, $this->currentLine); } - if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) { + if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine) && $newIndent === $indent) { $this->moveToPreviousLine(); break; } diff --git a/src/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml b/src/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml index fd8ad7ed44..0c96108e99 100644 --- a/src/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml +++ b/src/Symfony/Component/Yaml/Tests/Fixtures/unindentedCollections.yml @@ -60,3 +60,23 @@ yaml: | foo: bar php: | array('collection' => array('key' => array('a', 'b', 'c'), 'foo' => 'bar')) +--- +test: Shortcut Key after unindented collection +brief: > + Key/value after unindented collection +yaml: | + collection: + - key: foo + foo: bar +php: | + array('collection' => array(array('key' => 'foo', 'foo' => 'bar'))) +--- +test: Shortcut Key after unindented collection with custom spaces +brief: > + Key/value after unindented collection +yaml: | + collection: + - key: foo + foo: bar +php: | + array('collection' => array(array('key' => 'foo', 'foo' => 'bar'))) diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php index 5bda9c3be5..aca190ac8b 100644 --- a/src/Symfony/Component/Yaml/Tests/ParserTest.php +++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php @@ -475,6 +475,22 @@ collection: -item2 -item3 +EOF; + + $this->parser->parse($yaml); + } + + /** + * @expectedException \Symfony\Component\Yaml\Exception\ParseException + */ + public function testShortcutKeyUnindentedCollectionException() + { + $yaml = <<parser->parse($yaml); From 41c5be672f93f572994c009c6e4fbb3827b184cb Mon Sep 17 00:00:00 2001 From: Peter Rehm Date: Sun, 4 Jan 2015 13:46:16 +0100 Subject: [PATCH 4/9] Added the '-' character for spaceless on tag start and end to be consistent for block, if, set and for nodes --- .../views/Form/form_div_layout.html.twig | 240 +++++++++--------- .../views/Form/form_table_layout.html.twig | 20 +- 2 files changed, 130 insertions(+), 130 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig index badfa84926..3025450d79 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig @@ -1,19 +1,19 @@ {# Widgets #} -{% block form_widget -%} +{%- block form_widget -%} {% if compound %} {{- block('form_widget_compound') -}} {% else %} {{- block('form_widget_simple') -}} {% endif %} -{%- endblock form_widget %} +{%- endblock form_widget -%} -{% block form_widget_simple -%} +{%- block form_widget_simple -%} {%- set type = type|default('text') -%} -{%- endblock form_widget_simple %} +{%- endblock form_widget_simple -%} -{% block form_widget_compound -%} +{%- block form_widget_compound -%}
{%- if form.parent is empty -%} {{ form_errors(form) }} @@ -21,57 +21,57 @@ {{- block('form_rows') -}} {{- form_rest(form) -}}
-{%- endblock form_widget_compound %} +{%- endblock form_widget_compound -%} -{% block collection_widget -%} +{%- block collection_widget -%} {% if prototype is defined %} {%- set attr = attr|merge({'data-prototype': form_row(prototype) }) -%} {% endif %} {{- block('form_widget') -}} -{%- endblock collection_widget %} +{%- endblock collection_widget -%} -{% block textarea_widget -%} +{%- block textarea_widget -%} -{%- endblock textarea_widget %} +{%- endblock textarea_widget -%} -{% block choice_widget -%} +{%- block choice_widget -%} {% if expanded %} {{- block('choice_widget_expanded') -}} {% else %} {{- block('choice_widget_collapsed') -}} {% endif %} -{%- endblock choice_widget %} +{%- endblock choice_widget -%} -{% block choice_widget_expanded -%} +{%- block choice_widget_expanded -%}
{% for child in form %} {{- form_widget(child) -}} {{- form_label(child) -}} {% endfor %}
-{%- endblock choice_widget_expanded %} +{%- endblock choice_widget_expanded -%} -{% block choice_widget_collapsed -%} - {% if required and empty_value is none and not empty_value_in_choices and not multiple -%} +{%- block choice_widget_collapsed -%} + {%- if required and empty_value is none and not empty_value_in_choices and not multiple -%} {% set required = false %} {%- endif -%} -{%- endblock choice_widget_collapsed %} +{%- endblock choice_widget_collapsed -%} -{% block choice_widget_options -%} +{%- block choice_widget_options -%} {% for group_label, choice in options %} {%- if choice is iterable -%} @@ -82,31 +82,31 @@ {%- endif -%} {% endfor %} -{%- endblock choice_widget_options %} +{%- endblock choice_widget_options -%} -{% block checkbox_widget -%} +{%- block checkbox_widget -%} -{%- endblock checkbox_widget %} +{%- endblock checkbox_widget -%} -{% block radio_widget -%} +{%- block radio_widget -%} -{%- endblock radio_widget %} +{%- endblock radio_widget -%} -{% block datetime_widget -%} +{%- block datetime_widget -%} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} - {% else -%} + {%- else -%}
{{- form_errors(form.date) -}} {{- form_errors(form.time) -}} {{- form_widget(form.date) -}} {{- form_widget(form.time) -}}
- {%- endif %} -{%- endblock datetime_widget %} + {%- endif -%} +{%- endblock datetime_widget -%} -{% block date_widget -%} - {% if widget == 'single_text' -%} +{%- block date_widget -%} + {%- if widget == 'single_text' -%} {{ block('form_widget_simple') }} {%- else -%}
@@ -116,85 +116,85 @@ '{{ day }}': form_widget(form.day), })|raw -}}
- {%- endif %} -{%- endblock date_widget %} + {%- endif -%} +{%- endblock date_widget -%} -{% block time_widget -%} - {% if widget == 'single_text' -%} +{%- block time_widget -%} + {%- if widget == 'single_text' -%} {{ block('form_widget_simple') }} {%- else -%} - {% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%} + {%- set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%}
{{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %}
- {%- endif %} -{%- endblock time_widget %} + {%- endif -%} +{%- endblock time_widget -%} -{% block number_widget -%} +{%- block number_widget -%} {# type="number" doesn't work with floats #} {%- set type = type|default('text') -%} {{ block('form_widget_simple') }} -{%- endblock number_widget %} +{%- endblock number_widget -%} -{% block integer_widget -%} +{%- block integer_widget -%} {% set type = type|default('number') %} {{- block('form_widget_simple') -}} -{%- endblock integer_widget %} +{%- endblock integer_widget -%} -{% block money_widget -%} +{%- block money_widget -%} {{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }} -{%- endblock money_widget %} +{%- endblock money_widget -%} -{% block url_widget -%} - {% set type = type|default('url') -%} +{%- block url_widget -%} + {%- set type = type|default('url') -%} {{ block('form_widget_simple') }} -{%- endblock url_widget %} +{%- endblock url_widget -%} -{% block search_widget -%} - {% set type = type|default('search') -%} +{%- block search_widget -%} + {%- set type = type|default('search') -%} {{ block('form_widget_simple') }} -{%- endblock search_widget %} +{%- endblock search_widget -%} -{% block percent_widget -%} - {% set type = type|default('text') -%} +{%- block percent_widget -%} + {%- set type = type|default('text') -%} {{ block('form_widget_simple') }} % -{%- endblock percent_widget %} +{%- endblock percent_widget -%} -{% block password_widget -%} - {% set type = type|default('password') -%} +{%- block password_widget -%} + {%- set type = type|default('password') -%} {{ block('form_widget_simple') }} -{%- endblock password_widget %} +{%- endblock password_widget -%} -{% block hidden_widget -%} - {% set type = type|default('hidden') -%} +{%- block hidden_widget -%} + {%- set type = type|default('hidden') -%} {{ block('form_widget_simple') }} -{%- endblock hidden_widget %} +{%- endblock hidden_widget -%} -{% block email_widget -%} - {% set type = type|default('email') -%} +{%- block email_widget -%} + {%- set type = type|default('email') -%} {{ block('form_widget_simple') }} -{%- endblock email_widget %} +{%- endblock email_widget -%} -{% block button_widget -%} - {% if label is empty -%} +{%- block button_widget -%} + {%- if label is empty -%} {% set label = name|humanize %} {%- endif -%} -{%- endblock button_widget %} +{%- endblock button_widget -%} -{% block submit_widget -%} - {% set type = type|default('submit') -%} +{%- block submit_widget -%} + {%- set type = type|default('submit') -%} {{ block('button_widget') }} -{%- endblock submit_widget %} +{%- endblock submit_widget -%} -{% block reset_widget -%} - {% set type = type|default('reset') -%} +{%- block reset_widget -%} + {%- set type = type|default('reset') -%} {{ block('button_widget') }} -{%- endblock reset_widget %} +{%- endblock reset_widget -%} {# Labels #} -{% block form_label -%} +{%- block form_label -%} {% if label is not sameas(false) %} {%- if not compound -%} {% set label_attr = label_attr|merge({'for': id}) %} @@ -206,48 +206,48 @@ {% set label = name|humanize %} {%- endif -%} {{ label|trans({}, translation_domain) }} - {%- endif %} -{%- endblock form_label %} + {%- endif -%} +{%- endblock form_label -%} -{% block button_label -%}{%- endblock %} +{%- block button_label -%}{%- endblock -%} {# Rows #} -{% block repeated_row -%} +{%- block repeated_row -%} {# No need to render the errors here, as all errors are mapped to the first child (see RepeatedTypeValidatorExtension). #} - {{- block('form_rows') }} -{%- endblock repeated_row %} + {{- block('form_rows') -}} +{%- endblock repeated_row -%} -{% block form_row -%} +{%- block form_row -%}
{{- form_label(form) -}} {{- form_errors(form) -}} {{- form_widget(form) -}}
-{%- endblock form_row %} +{%- endblock form_row -%} -{% block button_row -%} +{%- block button_row -%}
{{- form_widget(form) -}}
-{%- endblock button_row %} +{%- endblock button_row -%} -{% block hidden_row -%} +{%- block hidden_row -%} {{ form_widget(form) }} -{%- endblock hidden_row %} +{%- endblock hidden_row -%} {# Misc #} -{% block form -%} +{%- block form -%} {{ form_start(form) }} {{- form_widget(form) -}} {{ form_end(form) }} -{%- endblock form %} +{%- endblock form -%} -{% block form_start -%} +{%- block form_start -%} {% set method = method|upper %} {%- if method in ["GET", "POST"] -%} {% set form_method = method %} @@ -257,57 +257,57 @@
{%- if form_method != method -%} - {%- endif %} -{%- endblock form_start %} + {%- endif -%} +{%- endblock form_start -%} -{% block form_end -%} - {% if not render_rest is defined or render_rest -%} +{%- block form_end -%} + {%- if not render_rest is defined or render_rest -%} {{ form_rest(form) }} {%- endif -%}
-{%- endblock form_end %} +{%- endblock form_end -%} -{% block form_enctype -%} +{%- block form_enctype -%} {% if multipart %}enctype="multipart/form-data"{% endif %} -{%- endblock form_enctype %} +{%- endblock form_enctype -%} -{% block form_errors -%} - {% if errors|length > 0 -%} +{%- block form_errors -%} + {%- if errors|length > 0 -%}
    {%- for error in errors -%}
  • {{ error.message }}
  • {%- endfor -%}
- {%- endif %} -{%- endblock form_errors %} + {%- endif -%} +{%- endblock form_errors -%} -{% block form_rest -%} - {% for child in form -%} - {% if not child.rendered -%} +{%- block form_rest -%} + {%- for child in form -%} + {%- if not child.rendered -%} {{ form_row(child) }} - {%- endif %} - {%- endfor %} -{%- endblock form_rest %} + {%- endif -%} + {%- endfor -%} +{%- endblock form_rest -%} {# Support #} -{% block form_rows -%} - {% for child in form -%} +{%- block form_rows -%} + {%- for child in form -%} {{ form_row(child) }} - {%- endfor %} -{%- endblock form_rows %} + {%- endfor -%} +{%- endblock form_rows -%} -{% block widget_attributes -%} +{%- block widget_attributes -%} id="{{ id }}" name="{{ full_name }}"{% if read_only %} readonly="readonly"{% endif %}{% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if pattern %} pattern="{{ pattern }}"{% endif %} - {%- for attrname, attrvalue in attr %} {% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}"{% else %}{{ attrname }}="{{ attrvalue }}"{% endif %}{% endfor %} -{%- endblock widget_attributes %} + {%- for attrname, attrvalue in attr %} {% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}"{% else %}{{ attrname }}="{{ attrvalue }}"{% endif %}{%- endfor -%} +{%- endblock widget_attributes -%} -{% block widget_container_attributes -%} +{%- block widget_container_attributes -%} {% if id is not empty %}id="{{ id }}" {% endif %} - {%- for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {% endfor %} -{%- endblock widget_container_attributes %} + {%- for attrname, attrvalue in attr %}{{ attrname }}="{{ attrvalue }}" {%- endfor -%} +{%- endblock widget_container_attributes -%} -{% block button_attributes -%} +{%- block button_attributes -%} id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif %} - {%- for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %} -{%- endblock button_attributes %} + {%- for attrname, attrvalue in attr %} {{ attrname }}="{{ attrvalue }}"{%- endfor -%} +{%- endblock button_attributes -%} diff --git a/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig b/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig index d3d7a34f40..c7b3a4365b 100644 --- a/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig +++ b/src/Symfony/Bridge/Twig/Resources/views/Form/form_table_layout.html.twig @@ -1,6 +1,6 @@ {% use "form_div_layout.html.twig" %} -{% block form_row -%} +{%- block form_row -%} {{- form_label(form) -}} @@ -10,35 +10,35 @@ {{- form_widget(form) -}} -{%- endblock form_row %} +{%- endblock form_row -%} -{% block button_row -%} +{%- block button_row -%} {{- form_widget(form) -}} -{%- endblock button_row %} +{%- endblock button_row -%} -{% block hidden_row -%} +{%- block hidden_row -%} {{- form_widget(form) -}} -{%- endblock hidden_row %} +{%- endblock hidden_row -%} -{% block form_widget_compound -%} +{%- block form_widget_compound -%} - {% if form.parent is empty and errors|length > 0 -%} + {%- if form.parent is empty and errors|length > 0 -%} - {%- endif %} + {%- endif -%} {{- block('form_rows') -}} {{- form_rest(form) -}}
{{- form_errors(form) -}}
-{%- endblock form_widget_compound %} +{%- endblock form_widget_compound -%} From 32338af211692d98d77724b1c8556891d4727acf Mon Sep 17 00:00:00 2001 From: Jakub Zalas Date: Mon, 19 Jan 2015 16:44:29 +0000 Subject: [PATCH 5/9] [Console] Make it clear that the second argument is not about command options. --- src/Symfony/Component/Console/Tester/CommandTester.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Console/Tester/CommandTester.php b/src/Symfony/Component/Console/Tester/CommandTester.php index 1806846a91..17c2918b6b 100644 --- a/src/Symfony/Component/Console/Tester/CommandTester.php +++ b/src/Symfony/Component/Console/Tester/CommandTester.php @@ -41,14 +41,14 @@ class CommandTester /** * Executes the command. * - * Available options: + * Available execution options: * * * interactive: Sets the input interactive flag * * decorated: Sets the output decorated flag * * verbosity: Sets the output verbosity flag * - * @param array $input An array of arguments and options - * @param array $options An array of options + * @param array $input An array of command arguments and options + * @param array $options An array of execution options * * @return int The command exit code */ From 7e19fab51c96abcdbc6f0f54382f237f1667c9b5 Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Tue, 20 Jan 2015 22:59:02 +0000 Subject: [PATCH 6/9] [FrameworkBundle][xsd] added missing logging attribute. --- .../FrameworkBundle/Resources/config/schema/symfony-1.0.xsd | 1 + .../Tests/DependencyInjection/Fixtures/xml/full.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 065846f1d3..5277da5c1e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -159,6 +159,7 @@ + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index 16aef6f09f..069e1cadb7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -42,7 +42,7 @@ theme2 - + From 50973bace145dfafd717a58d8512ab5963964ea3 Mon Sep 17 00:00:00 2001 From: sarah khalil Date: Wed, 21 Jan 2015 20:48:04 +0100 Subject: [PATCH 7/9] Removed dead code and various cleaning --- src/Symfony/Bridge/Twig/NodeVisitor/Scope.php | 10 +--------- src/Symfony/Component/Console/Application.php | 4 ++-- .../Compiler/CheckCircularReferencesPass.php | 2 -- src/Symfony/Component/HttpFoundation/Request.php | 2 +- src/Symfony/Component/Intl/Intl.php | 14 -------------- src/Symfony/Component/Process/Process.php | 3 +-- .../Component/PropertyAccess/PropertyPath.php | 5 ++--- .../Security/Acl/Dbal/MutableAclProvider.php | 3 --- .../PreAuthenticatedAuthenticationProvider.php | 6 +----- .../Security/Http/Firewall/AccessListener.php | 2 +- .../Security/Http/Firewall/ExceptionListener.php | 4 ++-- .../PersistentTokenBasedRememberMeServices.php | 2 +- 12 files changed, 12 insertions(+), 45 deletions(-) diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php b/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php index de4dc5ee96..ad7a7362f2 100644 --- a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php +++ b/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php @@ -21,11 +21,6 @@ class Scope */ private $parent; - /** - * @var Scope[] - */ - private $children; - /** * @var array */ @@ -53,10 +48,7 @@ class Scope */ public function enter() { - $child = new self($this); - $this->children[] = $child; - - return $child; + return new self($this); } /** diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 359ac69280..f01b4fdb51 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -754,8 +754,8 @@ class Application $trace = $e->getTrace(); array_unshift($trace, array( 'function' => '', - 'file' => $e->getFile() != null ? $e->getFile() : 'n/a', - 'line' => $e->getLine() != null ? $e->getLine() : 'n/a', + 'file' => $e->getFile() !== null ? $e->getFile() : 'n/a', + 'line' => $e->getLine() !== null ? $e->getLine() : 'n/a', 'args' => array(), )); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php index b959ba2cb2..d7570ddc2c 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckCircularReferencesPass.php @@ -26,7 +26,6 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; */ class CheckCircularReferencesPass implements CompilerPassInterface { - private $currentId; private $currentPath; private $checkedNodes; @@ -41,7 +40,6 @@ class CheckCircularReferencesPass implements CompilerPassInterface $this->checkedNodes = array(); foreach ($graph->getNodes() as $id => $node) { - $this->currentId = $id; $this->currentPath = array($id); $this->checkOutEdges($node->getOutEdges()); diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index b1ee9acb5c..3bbcb4ce72 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -446,7 +446,7 @@ class Request } if (!$dup->getRequestFormat(null)) { - $dup->setRequestFormat($format = $this->getRequestFormat(null)); + $dup->setRequestFormat($this->getRequestFormat(null)); } return $dup; diff --git a/src/Symfony/Component/Intl/Intl.php b/src/Symfony/Component/Intl/Intl.php index 5e9b39a3d9..58a3e84809 100644 --- a/src/Symfony/Component/Intl/Intl.php +++ b/src/Symfony/Component/Intl/Intl.php @@ -264,20 +264,6 @@ final class Intl return self::$entryReader; } - /** - * Resets the internal state. - */ - private static function reset() - { - self::$currencyBundle = null; - self::$languageBundle = null; - self::$localeBundle = null; - self::$regionBundle = null; - self::$icuVersion = false; - self::$icuDataVersion = false; - self::$entryReader = null; - } - /** * This class must not be instantiated. */ diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 2331b448a6..d762602925 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1040,8 +1040,7 @@ class Process { $that = $this; $out = self::OUT; - $err = self::ERR; - $callback = function ($type, $data) use ($that, $callback, $out, $err) { + $callback = function ($type, $data) use ($that, $callback, $out) { if ($out == $type) { $that->addOutput($data); } else { diff --git a/src/Symfony/Component/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index d872ce8a44..109902ce69 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyPath.php +++ b/src/Symfony/Component/PropertyAccess/PropertyPath.php @@ -109,8 +109,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface $element = $matches[3]; $this->isIndex[] = true; } - // Disabled this behaviour as the syntax is not yet final - //$pos = strpos($element, self::SINGULAR_SEPARATOR); + $pos = false; $singular = null; @@ -131,7 +130,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface throw new InvalidPropertyPathException(sprintf( 'Could not parse property path "%s". Unexpected token "%s" at position %d', $propertyPath, - $remaining{0}, + $remaining[0], $position )); } diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php index 1df371f798..f1b8afffb5 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php @@ -863,7 +863,6 @@ QUERY; $sids = new \SplObjectStorage(); $classIds = new \SplObjectStorage(); - $currentIds = array(); for ($i = 0, $c = count($new); $i<$c; $i++) { $ace = $new[$i]; @@ -890,8 +889,6 @@ QUERY; $aceIdProperty = new \ReflectionProperty($ace, 'id'); $aceIdProperty->setAccessible(true); $aceIdProperty->setValue($ace, intval($aceId)); - } else { - $currentIds[$ace->getId()] = true; } } } diff --git a/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php b/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php index b1e6c3845a..a73c244787 100644 --- a/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php +++ b/src/Symfony/Component/Security/Core/Authentication/Provider/PreAuthenticatedAuthenticationProvider.php @@ -59,11 +59,7 @@ class PreAuthenticatedAuthenticationProvider implements AuthenticationProviderIn if (!$user = $token->getUser()) { throw new BadCredentialsException('No pre-authenticated principal found in request.'); } -/* - if (null === $token->getCredentials()) { - throw new BadCredentialsException('No pre-authenticated credentials found in request.'); - } -*/ + $user = $this->userProvider->loadUserByUsername($user); $this->userChecker->checkPostAuth($user); diff --git a/src/Symfony/Component/Security/Http/Firewall/AccessListener.php b/src/Symfony/Component/Security/Http/Firewall/AccessListener.php index 9349012d00..ecb6a0923c 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AccessListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AccessListener.php @@ -55,7 +55,7 @@ class AccessListener implements ListenerInterface $request = $event->getRequest(); - list($attributes, $channel) = $this->map->getPatterns($request); + list($attributes) = $this->map->getPatterns($request); if (null === $attributes) { return; diff --git a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php index 58564dd86e..fac5dc1088 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php @@ -87,7 +87,7 @@ class ExceptionListener } elseif ($exception instanceof AccessDeniedException) { return $this->handleAccessDeniedException($event, $exception); } elseif ($exception instanceof LogoutException) { - return $this->handleLogoutException($event, $exception); + return $this->handleLogoutException($exception); } } while (null !== $exception = $exception->getPrevious()); } @@ -153,7 +153,7 @@ class ExceptionListener } } - private function handleLogoutException(GetResponseForExceptionEvent $event, LogoutException $exception) + private function handleLogoutException(LogoutException $exception) { if (null !== $this->logger) { $this->logger->info(sprintf('Logout exception occurred; wrapping with AccessDeniedHttpException (%s)', $exception->getMessage())); diff --git a/src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php b/src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php index d0a70b7592..f800668a5e 100644 --- a/src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php +++ b/src/Symfony/Component/Security/Http/RememberMe/PersistentTokenBasedRememberMeServices.php @@ -73,7 +73,7 @@ class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices if (null !== ($cookie = $request->cookies->get($this->options['name'])) && count($parts = $this->decodeCookie($cookie)) === 2 ) { - list($series, $tokenValue) = $parts; + list($series) = $parts; $this->tokenProvider->deleteTokenBySeries($series); } } From dbbe1701680bfabb64568f2731e7098ffe2ebace Mon Sep 17 00:00:00 2001 From: sarah khalil Date: Tue, 20 Jan 2015 22:49:28 +0100 Subject: [PATCH 8/9] Removed dead code and various cleaning --- .../Config/Definition/Dumper/XmlReferenceDumper.php | 2 +- .../Config/Definition/Dumper/YamlReferenceDumper.php | 1 - .../Component/Console/Descriptor/MarkdownDescriptor.php | 2 +- src/Symfony/Component/Debug/ExceptionHandler.php | 2 +- .../Compiler/CheckReferenceValidityPass.php | 1 - .../Component/HttpKernel/EventListener/DumpListener.php | 2 +- src/Symfony/Component/Process/Pipes/UnixPipes.php | 2 +- src/Symfony/Component/Process/Pipes/WindowsPipes.php | 2 +- src/Symfony/Component/PropertyAccess/PropertyAccessor.php | 2 -- .../Component/Security/Acl/Dbal/MutableAclProvider.php | 3 --- .../Component/Validator/Constraints/IsbnValidator.php | 2 +- .../Violation/LegacyConstraintViolationBuilder.php | 6 ------ src/Symfony/Component/VarDumper/Caster/DOMCaster.php | 2 -- 13 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index 10c4dd4f55..ab56a92838 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -59,7 +59,7 @@ class XmlReferenceDumper }); if (count($remapping)) { - list($singular, $plural) = current($remapping); + list($singular) = current($remapping); $rootName = $singular; } } diff --git a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php index a722955730..a7cd4486f2 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/YamlReferenceDumper.php @@ -14,7 +14,6 @@ namespace Symfony\Component\Config\Definition\Dumper; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\NodeInterface; use Symfony\Component\Config\Definition\ArrayNode; -use Symfony\Component\Config\Definition\ScalarNode; use Symfony\Component\Config\Definition\EnumNode; use Symfony\Component\Config\Definition\PrototypedArrayNode; use Symfony\Component\Yaml\Inline; diff --git a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php index db8f7df00a..78d48b9508 100644 --- a/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Component/Console/Descriptor/MarkdownDescriptor.php @@ -105,7 +105,7 @@ class MarkdownDescriptor extends Descriptor $this->write($help); } - if ($definition = $command->getNativeDefinition()) { + if ($command->getNativeDefinition()) { $this->write("\n\n"); $this->describeInputDefinition($command->getNativeDefinition()); } diff --git a/src/Symfony/Component/Debug/ExceptionHandler.php b/src/Symfony/Component/Debug/ExceptionHandler.php index 8c4c5fd422..3e87587773 100644 --- a/src/Symfony/Component/Debug/ExceptionHandler.php +++ b/src/Symfony/Component/Debug/ExceptionHandler.php @@ -50,7 +50,7 @@ class ExceptionHandler */ public static function register($debug = true, $fileLinkFormat = null) { - $handler = new static($debug, $fileLinkFormat = null); + $handler = new static($debug, $fileLinkFormat); $prev = set_exception_handler(array($handler, 'handle')); if (is_array($prev) && $prev[0] instanceof ErrorHandler) { diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php index e704443989..3d4988d2e6 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php @@ -33,7 +33,6 @@ class CheckReferenceValidityPass implements CompilerPassInterface { private $container; private $currentId; - private $currentDefinition; private $currentScope; private $currentScopeAncestors; private $currentScopeChildren; diff --git a/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php b/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php index 4ba9f58da2..bccde8eb95 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DumpListener.php @@ -24,7 +24,7 @@ use Symfony\Component\VarDumper\VarDumper; */ class DumpListener implements EventSubscriberInterface { - private $container; + private $cloner; private $dumper; /** diff --git a/src/Symfony/Component/Process/Pipes/UnixPipes.php b/src/Symfony/Component/Process/Pipes/UnixPipes.php index 6150d4a709..b3841031c4 100644 --- a/src/Symfony/Component/Process/Pipes/UnixPipes.php +++ b/src/Symfony/Component/Process/Pipes/UnixPipes.php @@ -172,7 +172,7 @@ class UnixPipes extends AbstractPipes } if (null !== $w && 0 < count($w)) { - while ($len = strlen($this->inputBuffer)) { + while (strlen($this->inputBuffer)) { $written = fwrite($w[0], $this->inputBuffer, 2 << 18); // write 512k if ($written > 0) { $this->inputBuffer = (string) substr($this->inputBuffer, $written); diff --git a/src/Symfony/Component/Process/Pipes/WindowsPipes.php b/src/Symfony/Component/Process/Pipes/WindowsPipes.php index 86cde67d02..01dd5d0600 100644 --- a/src/Symfony/Component/Process/Pipes/WindowsPipes.php +++ b/src/Symfony/Component/Process/Pipes/WindowsPipes.php @@ -235,7 +235,7 @@ class WindowsPipes extends AbstractPipes } if (null !== $w && 0 < count($w)) { - while ($len = strlen($this->inputBuffer)) { + while (strlen($this->inputBuffer)) { $written = fwrite($w[0], $this->inputBuffer, 2 << 18); if ($written > 0) { $this->inputBuffer = (string) substr($this->inputBuffer, $written); diff --git a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php index e1fa7e0961..5514cb2ba6 100644 --- a/src/Symfony/Component/PropertyAccess/PropertyAccessor.php +++ b/src/Symfony/Component/PropertyAccess/PropertyAccessor.php @@ -579,8 +579,6 @@ class PropertyAccessor implements PropertyAccessorInterface */ private function findAdderAndRemover(\ReflectionClass $reflClass, array $singulars) { - $exception = null; - foreach ($singulars as $singular) { $addMethod = 'add'.$singular; $removeMethod = 'remove'.$singular; diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php index 8e6b53644d..bd255022f0 100644 --- a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php +++ b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php @@ -853,7 +853,6 @@ QUERY; { $sids = new \SplObjectStorage(); $classIds = new \SplObjectStorage(); - $currentIds = array(); foreach ($changes[1] as $field => $new) { for ($i = 0, $c = count($new); $i<$c; $i++) { $ace = $new[$i]; @@ -881,8 +880,6 @@ QUERY; $aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id'); $aceIdProperty->setAccessible(true); $aceIdProperty->setValue($ace, intval($aceId)); - } else { - $currentIds[$ace->getId()] = true; } } } diff --git a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php index 8a53fe7941..94d26d7b6e 100644 --- a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php @@ -46,7 +46,7 @@ class IsbnValidator extends ConstraintValidator $value = (string) $value; $canonical = str_replace('-', '', $value); - if (null == $constraint->type) { + if (null === $constraint->type) { if ($constraint->isbn10 && !$constraint->isbn13) { $constraint->type = 'isbn10'; } elseif ($constraint->isbn13 && !$constraint->isbn10) { diff --git a/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php b/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php index 0607552cfc..5519f42de9 100644 --- a/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php +++ b/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php @@ -40,11 +40,6 @@ class LegacyConstraintViolationBuilder implements ConstraintViolationBuilderInte */ private $parameters; - /** - * @var mixed - */ - private $root; - /** * @var mixed */ @@ -70,7 +65,6 @@ class LegacyConstraintViolationBuilder implements ConstraintViolationBuilderInte $this->context = $context; $this->message = $message; $this->parameters = $parameters; - $this->root = $context->getRoot(); $this->invalidValue = $context->getValue(); } diff --git a/src/Symfony/Component/VarDumper/Caster/DOMCaster.php b/src/Symfony/Component/VarDumper/Caster/DOMCaster.php index 39abce5db8..d5b3c87a73 100644 --- a/src/Symfony/Component/VarDumper/Caster/DOMCaster.php +++ b/src/Symfony/Component/VarDumper/Caster/DOMCaster.php @@ -115,8 +115,6 @@ class DOMCaster public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, $isNested) { - // Commented lines denote properties that exist but are better not dumped for clarity. - $a += array( 'nodeName' => $dom->nodeName, 'nodeValue' => new CutStub($dom->nodeValue), From 1e4a8d55cbcb8c105536a389133059c3a145ba10 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Sat, 24 Jan 2015 20:09:16 -0300 Subject: [PATCH 9/9] [2.3] [HttpFoundation] [MimeTypeGuesser] Updated exception message in MimeTypeGuesser when no guessers available (issue #12857). | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #12857 | License | MIT | Doc PR | none --- .../HttpFoundation/File/MimeType/MimeTypeGuesser.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php b/src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php index 8812f04a03..81b2b02bd4 100644 --- a/src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php +++ b/src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php @@ -120,7 +120,11 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface } if (!$this->guessers) { - throw new \LogicException('Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)'); + $msg = 'Unable to guess the mime type as no guessers are available'; + if (!FileinfoMimeTypeGuesser::isSupported()) { + $msg .= ' (Did you enable the php_fileinfo extension?)'; + } + throw new \LogicException($msg); } foreach ($this->guessers as $guesser) {