diff --git a/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php b/src/Symfony/Bridge/Twig/NodeVisitor/Scope.php index 635c54ece2..1712bd5afe 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 */ @@ -51,10 +46,7 @@ class Scope */ public function enter() { - $child = new self($this); - $this->children[] = $child; - - return $child; + return new self($this); } /** 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 8938637548..b39dbf1c80 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 -%} - {% set type = type|default('text') -%} +{%- 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 placeholder is none and not placeholder_in_choices and not multiple -%} +{%- block choice_widget_collapsed -%} + {%- if required and placeholder is none and not placeholder_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,33 +82,33 @@ {%- 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('form_widget_simple') -}} - {% else -%} +{%- block date_widget -%} + {%- if widget == 'single_text' -%} + {{ block('form_widget_simple') }} + {%- else -%}
{{- date_pattern|replace({ '{{ year }}': form_widget(form.year), @@ -116,67 +116,67 @@ '{{ day }}': form_widget(form.day), })|raw -}}
- {%- endif %} -{%- endblock date_widget %} + {%- endif -%} +{%- endblock date_widget -%} -{% block time_widget -%} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {% else -%} - {% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} %} +{%- block time_widget -%} + {%- if widget == 'single_text' -%} + {{ block('form_widget_simple') }} + {%- else -%} + {%- 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 %} + {%- set type = type|default('text') -%} + {{ block('form_widget_simple') }} +{%- endblock number_widget -%} -{% block integer_widget -%} - {% set type = type|default('number') %} - {{- block('form_widget_simple') -}} -{%- endblock integer_widget %} +{%- block integer_widget -%} + {%- set type = type|default('number') -%} + {{ block('form_widget_simple') }} +{%- 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('form_widget_simple') -}} -{%- endblock url_widget %} +{%- block url_widget -%} + {%- set type = type|default('url') -%} + {{ block('form_widget_simple') }} +{%- endblock url_widget -%} -{% block search_widget -%} - {% set type = type|default('search') %} - {{- block('form_widget_simple') -}} -{%- endblock search_widget %} +{%- block search_widget -%} + {%- set type = type|default('search') -%} + {{ block('form_widget_simple') }} +{%- endblock search_widget -%} -{% block percent_widget -%} - {% set type = type|default('text') %} - {{- block('form_widget_simple') -}} % -{%- endblock percent_widget %} +{%- block percent_widget -%} + {%- set type = type|default('text') -%} + {{ block('form_widget_simple') }} % +{%- endblock percent_widget -%} -{% block password_widget -%} - {% set type = type|default('password') %} - {{- block('form_widget_simple') -}} -{%- endblock password_widget %} +{%- block password_widget -%} + {%- set type = type|default('password') -%} + {{ block('form_widget_simple') }} +{%- endblock password_widget -%} -{% block hidden_widget -%} - {% set type = type|default('hidden') %} - {{- block('form_widget_simple') -}} +{%- block hidden_widget -%} + {%- set type = type|default('hidden') -%} + {{ block('form_widget_simple') }} {%- endblock hidden_widget -%} -{% block email_widget -%} - {% set type = type|default('email') %} - {{- block('form_widget_simple') -}} -{%- endblock email_widget %} +{%- block email_widget -%} + {%- set type = type|default('email') -%} + {{ block('form_widget_simple') }} +{%- endblock email_widget -%} -{% block button_widget -%} - {% if label is empty -%} +{%- block button_widget -%} + {%- if label is empty -%} {%- if label_format is not empty -%} {% set label = label_format|replace({ '%name%': name, @@ -187,21 +187,21 @@ {%- endif -%} {%- endif -%} -{%- endblock button_widget %} +{%- endblock button_widget -%} -{% block submit_widget -%} - {% set type = type|default('submit') %} - {{- block('button_widget') -}} -{%- endblock submit_widget %} +{%- block submit_widget -%} + {%- set type = type|default('submit') -%} + {{ block('button_widget') }} +{%- endblock submit_widget -%} -{% block reset_widget -%} - {% set type = type|default('reset') %} - {{- block('button_widget') -}} -{%- endblock reset_widget %} +{%- block reset_widget -%} + {%- set type = type|default('reset') -%} + {{ block('button_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}) %} @@ -220,48 +220,48 @@ {%- endif -%} {%- 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 %} +{%- 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 %} @@ -272,30 +272,30 @@ {%- if form_method != method -%} {%- endif -%} -{%- endblock form_start %} +{%- endblock form_start -%} -{% block form_end -%} - {% if not render_rest is defined or render_rest %} - {{- form_rest(form) -}} - {% endif -%} +{%- 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 -%} - {%- endif %} -{%- endblock form_errors %} + {%- endif -%} +{%- endblock form_errors -%} -{% block form_rest -%} +{%- block form_rest -%} {% for child in form -%} {% if not child.rendered %} {{- form_row(child) -}} @@ -305,13 +305,13 @@ {# Support #} -{% block form_rows -%} +{%- block form_rows -%} {% for child in form %} {{- form_row(child) -}} {% endfor %} -{%- endblock form_rows %} +{%- 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 -%} @@ -326,9 +326,9 @@ {{- attrname }}="{{ attrvalue }}" {%- endif -%} {%- endfor -%} -{%- endblock widget_attributes %} +{%- endblock widget_attributes -%} -{% block widget_container_attributes -%} +{%- block widget_container_attributes -%} {%- if id is not empty %}id="{{ id }}"{% endif -%} {%- for attrname, attrvalue in attr -%} {{- " " -}} @@ -340,9 +340,9 @@ {{- attrname }}="{{ attrvalue }}" {%- endif -%} {%- endfor -%} -{%- endblock widget_container_attributes %} +{%- 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 -%} {{- " " -}} @@ -354,4 +354,4 @@ {{- attrname }}="{{ attrvalue }}" {%- endif -%} {%- endfor -%} -{%- endblock button_attributes %} +{%- 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 5c85128f5a..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,26 +10,26 @@ {{- 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 -%} @@ -37,8 +37,8 @@ {{- form_errors(form) -}} - {%- endif %} + {%- endif -%} {{- block('form_rows') -}} {{- form_rest(form) -}}
-{%- endblock form_widget_compound %} +{%- endblock form_widget_compound -%} 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 fc6d336a31..024cef66cc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -44,7 +44,7 @@ theme2 - + 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/Application.php b/src/Symfony/Component/Console/Application.php index baea10ab7d..e16342b1d2 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -460,10 +460,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)); } } @@ -712,8 +712,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(), )); @@ -1150,4 +1150,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/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/Console/Tester/CommandTester.php b/src/Symfony/Component/Console/Tester/CommandTester.php index f6079c63b5..a6d5359452 100644 --- a/src/Symfony/Component/Console/Tester/CommandTester.php +++ b/src/Symfony/Component/Console/Tester/CommandTester.php @@ -42,14 +42,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 */ diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php index cfcd9363ce..912295aa14 100644 --- a/src/Symfony/Component/Console/Tests/ApplicationTest.php +++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php @@ -45,6 +45,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase require_once self::$fixturesPath.'/Foo5Command.php'; require_once self::$fixturesPath.'/FoobarCommand.php'; require_once self::$fixturesPath.'/BarBucCommand.php'; + require_once self::$fixturesPath.'/FooSubnamespaced1Command.php'; + require_once self::$fixturesPath.'/FooSubnamespaced2Command.php'; } protected function normalizeLineBreaks($text) @@ -201,6 +203,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; + } +} 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/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/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/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) { diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 95cf25eeb6..3f63312d46 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -480,7 +480,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/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/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/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index b9ecd71abe..d21b85f394 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; @@ -630,6 +631,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 c8a79bd7e5..2e9790739f 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\HttpKernelInterface; use Symfony\Component\HttpFoundation\Request; @@ -111,6 +112,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->getKernel(array('initializeBundles', 'initializeContainer')); 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/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/Process/Process.php b/src/Symfony/Component/Process/Process.php index 9242eb3f72..b8d863af50 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -1295,8 +1295,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/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/PropertyAccess/PropertyPath.php b/src/Symfony/Component/PropertyAccess/PropertyPath.php index bdcc85b340..34cf1bbe60 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; diff --git a/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php b/src/Symfony/Component/Security/Acl/Dbal/MutableAclProvider.php index 8e6b53644d..edf997b783 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; } } } @@ -931,7 +928,6 @@ QUERY; $sids = new \SplObjectStorage(); $classIds = new \SplObjectStorage(); - $currentIds = array(); for ($i = 0, $c = count($new); $i<$c; $i++) { $ace = $new[$i]; @@ -958,8 +954,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 11c3cda241..4f732542ea 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 93d20bedb9..6fd68f3b23 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 7001532de4..213a837a6f 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php @@ -94,7 +94,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()); } @@ -160,7 +160,7 @@ class ExceptionListener } } - private function handleLogoutException(GetResponseForExceptionEvent $event, LogoutException $exception) + private function handleLogoutException(LogoutException $exception) { if (null !== $this->logger) { $this->logger->info('A LogoutException was thrown.', array('exception' => $exception)); 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); } } diff --git a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php index 68c027fd9f..63c20b7f24 100644 --- a/src/Symfony/Component/Validator/Constraints/IsbnValidator.php +++ b/src/Symfony/Component/Validator/Constraints/IsbnValidator.php @@ -47,7 +47,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) { trigger_error('The "isbn10" option of the Isbn constraint is deprecated since version 2.5 and will be removed in 3.0. Use the "type" option instead.', E_USER_DEPRECATED); $constraint->type = 'isbn10'; diff --git a/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php b/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php index 01effe46c8..0ce6da9060 100644 --- a/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php +++ b/src/Symfony/Component/Validator/Violation/LegacyConstraintViolationBuilder.php @@ -42,11 +42,6 @@ class LegacyConstraintViolationBuilder implements ConstraintViolationBuilderInte */ private $parameters; - /** - * @var mixed - */ - private $root; - /** * @var mixed */ @@ -72,7 +67,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), diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 6b0697accc..e9a94d7785 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -98,7 +98,6 @@ class Parser $data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport, $objectForMap); } 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 @@ -108,7 +107,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, $objectForMap); @@ -349,7 +348,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 @@ -372,7 +378,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 db9734499e..553d2fb5de 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);