Merge branch '2.6' into 2.7

* 2.6:
  [2.3] [HttpFoundation] [MimeTypeGuesser]
  Removed dead code and various cleaning
  Removed dead code and various cleaning
  [FrameworkBundle][xsd] added missing logging attribute.
  [Console] Make it clear that the second argument is not about command options.
  Added the '-' character for spaceless on tag start and end to be consistent for block, if, set and for nodes
  [Yaml] fixed parse shortcut Key after unindented collection.
  [Console] fixed #10531
  Make the container considered non-fresh if the environment parameters are changed
This commit is contained in:
Fabien Potencier 2015-01-25 05:39:35 +01:00
commit 2570042937
40 changed files with 530 additions and 212 deletions

View File

@ -21,11 +21,6 @@ class Scope
*/ */
private $parent; private $parent;
/**
* @var Scope[]
*/
private $children;
/** /**
* @var array * @var array
*/ */
@ -51,10 +46,7 @@ class Scope
*/ */
public function enter() public function enter()
{ {
$child = new self($this); return new self($this);
$this->children[] = $child;
return $child;
} }
/** /**

View File

@ -1,19 +1,19 @@
{# Widgets #} {# Widgets #}
{% block form_widget -%} {%- block form_widget -%}
{% if compound %} {% if compound %}
{{- block('form_widget_compound') -}} {{- block('form_widget_compound') -}}
{% else %} {% else %}
{{- block('form_widget_simple') -}} {{- block('form_widget_simple') -}}
{% endif %} {% endif %}
{%- endblock form_widget %} {%- endblock form_widget -%}
{% block form_widget_simple -%} {%- block form_widget_simple -%}
{% set type = type|default('text') -%} {%- set type = type|default('text') -%}
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/> <input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{%- endblock form_widget_simple %} {%- endblock form_widget_simple -%}
{% block form_widget_compound -%} {%- block form_widget_compound -%}
<div {{ block('widget_container_attributes') }}> <div {{ block('widget_container_attributes') }}>
{%- if form.parent is empty -%} {%- if form.parent is empty -%}
{{ form_errors(form) }} {{ form_errors(form) }}
@ -21,57 +21,57 @@
{{- block('form_rows') -}} {{- block('form_rows') -}}
{{- form_rest(form) -}} {{- form_rest(form) -}}
</div> </div>
{%- endblock form_widget_compound %} {%- endblock form_widget_compound -%}
{% block collection_widget -%} {%- block collection_widget -%}
{% if prototype is defined %} {% if prototype is defined %}
{%- set attr = attr|merge({'data-prototype': form_row(prototype) }) -%} {%- set attr = attr|merge({'data-prototype': form_row(prototype) }) -%}
{% endif %} {% endif %}
{{- block('form_widget') -}} {{- block('form_widget') -}}
{%- endblock collection_widget %} {%- endblock collection_widget -%}
{% block textarea_widget -%} {%- block textarea_widget -%}
<textarea {{ block('widget_attributes') }}>{{ value }}</textarea> <textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
{%- endblock textarea_widget %} {%- endblock textarea_widget -%}
{% block choice_widget -%} {%- block choice_widget -%}
{% if expanded %} {% if expanded %}
{{- block('choice_widget_expanded') -}} {{- block('choice_widget_expanded') -}}
{% else %} {% else %}
{{- block('choice_widget_collapsed') -}} {{- block('choice_widget_collapsed') -}}
{% endif %} {% endif %}
{%- endblock choice_widget %} {%- endblock choice_widget -%}
{% block choice_widget_expanded -%} {%- block choice_widget_expanded -%}
<div {{ block('widget_container_attributes') }}> <div {{ block('widget_container_attributes') }}>
{%- for child in form %} {%- for child in form %}
{{- form_widget(child) -}} {{- form_widget(child) -}}
{{- form_label(child) -}} {{- form_label(child) -}}
{% endfor -%} {% endfor -%}
</div> </div>
{% endblock choice_widget_expanded %} {%- endblock choice_widget_expanded -%}
{% block choice_widget_collapsed -%} {%- block choice_widget_collapsed -%}
{% if required and placeholder is none and not placeholder_in_choices and not multiple -%} {%- if required and placeholder is none and not placeholder_in_choices and not multiple -%}
{% set required = false %} {% set required = false %}
{%- endif -%} {%- endif -%}
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}> <select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>
{% if placeholder is not none -%} {%- if placeholder is not none -%}
<option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder|trans({}, translation_domain) }}</option> <option value=""{% if required and value is empty %} selected="selected"{% endif %}>{{ placeholder|trans({}, translation_domain) }}</option>
{%- endif %} {%- endif -%}
{%- if preferred_choices|length > 0 -%} {%- if preferred_choices|length > 0 -%}
{% set options = preferred_choices %} {% set options = preferred_choices %}
{{- block('choice_widget_options') -}} {{- block('choice_widget_options') -}}
{% if choices|length > 0 and separator is not none -%} {%- if choices|length > 0 and separator is not none -%}
<option disabled="disabled">{{ separator }}</option> <option disabled="disabled">{{ separator }}</option>
{%- endif %} {%- endif -%}
{%- endif -%} {%- endif -%}
{% set options = choices -%} {%- set options = choices -%}
{{- block('choice_widget_options') -}} {{- block('choice_widget_options') -}}
</select> </select>
{%- endblock choice_widget_collapsed %} {%- endblock choice_widget_collapsed -%}
{% block choice_widget_options -%} {%- block choice_widget_options -%}
{% for group_label, choice in options %} {% for group_label, choice in options %}
{%- if choice is iterable -%} {%- if choice is iterable -%}
<optgroup label="{{ group_label|trans({}, translation_domain) }}"> <optgroup label="{{ group_label|trans({}, translation_domain) }}">
@ -82,33 +82,33 @@
<option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice.label|trans({}, translation_domain) }}</option> <option value="{{ choice.value }}"{% if choice is selectedchoice(value) %} selected="selected"{% endif %}>{{ choice.label|trans({}, translation_domain) }}</option>
{%- endif -%} {%- endif -%}
{% endfor %} {% endfor %}
{%- endblock choice_widget_options %} {%- endblock choice_widget_options -%}
{% block checkbox_widget -%} {%- block checkbox_widget -%}
<input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> <input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
{%- endblock checkbox_widget %} {%- endblock checkbox_widget -%}
{% block radio_widget -%} {%- block radio_widget -%}
<input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} /> <input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
{%- endblock radio_widget %} {%- endblock radio_widget -%}
{% block datetime_widget -%} {%- block datetime_widget -%}
{% if widget == 'single_text' %} {% if widget == 'single_text' %}
{{- block('form_widget_simple') -}} {{- block('form_widget_simple') -}}
{% else -%} {%- else -%}
<div {{ block('widget_container_attributes') }}> <div {{ block('widget_container_attributes') }}>
{{- form_errors(form.date) -}} {{- form_errors(form.date) -}}
{{- form_errors(form.time) -}} {{- form_errors(form.time) -}}
{{- form_widget(form.date) -}} {{- form_widget(form.date) -}}
{{- form_widget(form.time) -}} {{- form_widget(form.time) -}}
</div> </div>
{%- endif %} {%- endif -%}
{%- endblock datetime_widget %} {%- endblock datetime_widget -%}
{% block date_widget -%} {%- block date_widget -%}
{% if widget == 'single_text' %} {%- if widget == 'single_text' -%}
{{- block('form_widget_simple') -}} {{ block('form_widget_simple') }}
{% else -%} {%- else -%}
<div {{ block('widget_container_attributes') }}> <div {{ block('widget_container_attributes') }}>
{{- date_pattern|replace({ {{- date_pattern|replace({
'{{ year }}': form_widget(form.year), '{{ year }}': form_widget(form.year),
@ -116,67 +116,67 @@
'{{ day }}': form_widget(form.day), '{{ day }}': form_widget(form.day),
})|raw -}} })|raw -}}
</div> </div>
{%- endif %} {%- endif -%}
{%- endblock date_widget %} {%- endblock date_widget -%}
{% block time_widget -%} {%- block time_widget -%}
{% if widget == 'single_text' %} {%- if widget == 'single_text' -%}
{{- block('form_widget_simple') -}} {{ block('form_widget_simple') }}
{% else -%} {%- else -%}
{% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} %} {%- set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%}
<div {{ block('widget_container_attributes') }}> <div {{ block('widget_container_attributes') }}>
{{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %} {{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %}
</div> </div>
{%- endif %} {%- endif -%}
{%- endblock time_widget %} {%- endblock time_widget -%}
{% block number_widget -%} {%- block number_widget -%}
{# type="number" doesn't work with floats #} {# type="number" doesn't work with floats #}
{%- set type = type|default('text') %} {%- set type = type|default('text') -%}
{{- block('form_widget_simple') -}} {{ block('form_widget_simple') }}
{%- endblock number_widget %} {%- endblock number_widget -%}
{% block integer_widget -%} {%- block integer_widget -%}
{% set type = type|default('number') %} {%- set type = type|default('number') -%}
{{- block('form_widget_simple') -}} {{ 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 }} {{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }}
{%- endblock money_widget %} {%- endblock money_widget -%}
{% block url_widget -%} {%- block url_widget -%}
{% set type = type|default('url') %} {%- set type = type|default('url') -%}
{{- block('form_widget_simple') -}} {{ block('form_widget_simple') }}
{%- endblock url_widget %} {%- endblock url_widget -%}
{% block search_widget -%} {%- block search_widget -%}
{% set type = type|default('search') %} {%- set type = type|default('search') -%}
{{- block('form_widget_simple') -}} {{ block('form_widget_simple') }}
{%- endblock search_widget %} {%- endblock search_widget -%}
{% block percent_widget -%} {%- block percent_widget -%}
{% set type = type|default('text') %} {%- set type = type|default('text') -%}
{{- block('form_widget_simple') -}} % {{ block('form_widget_simple') }} %
{%- endblock percent_widget %} {%- endblock percent_widget -%}
{% block password_widget -%} {%- block password_widget -%}
{% set type = type|default('password') %} {%- set type = type|default('password') -%}
{{- block('form_widget_simple') -}} {{ block('form_widget_simple') }}
{%- endblock password_widget %} {%- endblock password_widget -%}
{% block hidden_widget -%} {%- block hidden_widget -%}
{% set type = type|default('hidden') %} {%- set type = type|default('hidden') -%}
{{- block('form_widget_simple') -}} {{ block('form_widget_simple') }}
{%- endblock hidden_widget -%} {%- endblock hidden_widget -%}
{% block email_widget -%} {%- block email_widget -%}
{% set type = type|default('email') %} {%- set type = type|default('email') -%}
{{- block('form_widget_simple') -}} {{ block('form_widget_simple') }}
{%- endblock email_widget %} {%- endblock email_widget -%}
{% block button_widget -%} {%- block button_widget -%}
{% if label is empty -%} {%- if label is empty -%}
{%- if label_format is not empty -%} {%- if label_format is not empty -%}
{% set label = label_format|replace({ {% set label = label_format|replace({
'%name%': name, '%name%': name,
@ -187,21 +187,21 @@
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
<button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ label|trans({}, translation_domain) }}</button> <button type="{{ type|default('button') }}" {{ block('button_attributes') }}>{{ label|trans({}, translation_domain) }}</button>
{%- endblock button_widget %} {%- endblock button_widget -%}
{% block submit_widget -%} {%- block submit_widget -%}
{% set type = type|default('submit') %} {%- set type = type|default('submit') -%}
{{- block('button_widget') -}} {{ block('button_widget') }}
{%- endblock submit_widget %} {%- endblock submit_widget -%}
{% block reset_widget -%} {%- block reset_widget -%}
{% set type = type|default('reset') %} {%- set type = type|default('reset') -%}
{{- block('button_widget') -}} {{ block('button_widget') }}
{%- endblock reset_widget %} {%- endblock reset_widget -%}
{# Labels #} {# Labels #}
{% block form_label -%} {%- block form_label -%}
{% if label is not sameas(false) -%} {% if label is not sameas(false) -%}
{% if not compound -%} {% if not compound -%}
{% set label_attr = label_attr|merge({'for': id}) %} {% set label_attr = label_attr|merge({'for': id}) %}
@ -220,48 +220,48 @@
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label|trans({}, translation_domain) }}</label> <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>{{ label|trans({}, translation_domain) }}</label>
{%- endif %} {%- endif -%}
{%- endblock form_label %} {%- endblock form_label -%}
{% block button_label -%}{%- endblock %} {%- block button_label -%}{%- endblock -%}
{# Rows #} {# Rows #}
{% block repeated_row -%} {%- block repeated_row -%}
{# {#
No need to render the errors here, as all errors are mapped No need to render the errors here, as all errors are mapped
to the first child (see RepeatedTypeValidatorExtension). to the first child (see RepeatedTypeValidatorExtension).
#} #}
{{- block('form_rows') -}} {{- block('form_rows') -}}
{%- endblock repeated_row %} {%- endblock repeated_row -%}
{% block form_row -%} {%- block form_row -%}
<div> <div>
{{- form_label(form) -}} {{- form_label(form) -}}
{{- form_errors(form) -}} {{- form_errors(form) -}}
{{- form_widget(form) -}} {{- form_widget(form) -}}
</div> </div>
{%- endblock form_row %} {%- endblock form_row -%}
{% block button_row -%} {%- block button_row -%}
<div> <div>
{{- form_widget(form) -}} {{- form_widget(form) -}}
</div> </div>
{%- endblock button_row %} {%- endblock button_row -%}
{% block hidden_row -%} {%- block hidden_row -%}
{{ form_widget(form) }} {{ form_widget(form) }}
{%- endblock hidden_row %} {%- endblock hidden_row -%}
{# Misc #} {# Misc #}
{% block form -%} {%- block form -%}
{{ form_start(form) }} {{ form_start(form) }}
{{- form_widget(form) -}} {{- form_widget(form) -}}
{{ form_end(form) }} {{ form_end(form) }}
{%- endblock form %} {%- endblock form -%}
{% block form_start -%} {%- block form_start -%}
{% set method = method|upper %} {% set method = method|upper %}
{%- if method in ["GET", "POST"] -%} {%- if method in ["GET", "POST"] -%}
{% set form_method = method %} {% set form_method = method %}
@ -272,30 +272,30 @@
{%- if form_method != method -%} {%- if form_method != method -%}
<input type="hidden" name="_method" value="{{ method }}" /> <input type="hidden" name="_method" value="{{ method }}" />
{%- endif -%} {%- endif -%}
{%- endblock form_start %} {%- endblock form_start -%}
{% block form_end -%} {%- block form_end -%}
{% if not render_rest is defined or render_rest %} {%- if not render_rest is defined or render_rest -%}
{{- form_rest(form) -}} {{ form_rest(form) }}
{% endif -%} {%- endif -%}
</form> </form>
{%- endblock form_end %} {%- endblock form_end -%}
{% block form_enctype -%} {%- block form_enctype -%}
{% if multipart %}enctype="multipart/form-data"{% endif %} {% if multipart %}enctype="multipart/form-data"{% endif %}
{%- endblock form_enctype %} {%- endblock form_enctype -%}
{% block form_errors -%} {%- block form_errors -%}
{% if errors|length > 0 -%} {%- if errors|length > 0 -%}
<ul> <ul>
{%- for error in errors -%} {%- for error in errors -%}
<li>{{ error.message }}</li> <li>{{ error.message }}</li>
{%- endfor -%} {%- endfor -%}
</ul> </ul>
{%- endif %} {%- endif -%}
{%- endblock form_errors %} {%- endblock form_errors -%}
{% block form_rest -%} {%- block form_rest -%}
{% for child in form -%} {% for child in form -%}
{% if not child.rendered %} {% if not child.rendered %}
{{- form_row(child) -}} {{- form_row(child) -}}
@ -305,13 +305,13 @@
{# Support #} {# Support #}
{% block form_rows -%} {%- block form_rows -%}
{% for child in form %} {% for child in form %}
{{- form_row(child) -}} {{- form_row(child) -}}
{% endfor %} {% endfor %}
{%- endblock form_rows %} {%- endblock form_rows -%}
{% block widget_attributes -%} {%- block widget_attributes -%}
id="{{ id }}" name="{{ full_name }}" id="{{ id }}" name="{{ full_name }}"
{%- if read_only %} readonly="readonly"{% endif -%} {%- if read_only %} readonly="readonly"{% endif -%}
{%- if disabled %} disabled="disabled"{% endif -%} {%- if disabled %} disabled="disabled"{% endif -%}
@ -326,9 +326,9 @@
{{- attrname }}="{{ attrvalue }}" {{- attrname }}="{{ attrvalue }}"
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- endblock widget_attributes %} {%- endblock widget_attributes -%}
{% block widget_container_attributes -%} {%- block widget_container_attributes -%}
{%- if id is not empty %}id="{{ id }}"{% endif -%} {%- if id is not empty %}id="{{ id }}"{% endif -%}
{%- for attrname, attrvalue in attr -%} {%- for attrname, attrvalue in attr -%}
{{- " " -}} {{- " " -}}
@ -340,9 +340,9 @@
{{- attrname }}="{{ attrvalue }}" {{- attrname }}="{{ attrvalue }}"
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- 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 -%} id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif -%}
{%- for attrname, attrvalue in attr -%} {%- for attrname, attrvalue in attr -%}
{{- " " -}} {{- " " -}}
@ -354,4 +354,4 @@
{{- attrname }}="{{ attrvalue }}" {{- attrname }}="{{ attrvalue }}"
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- endblock button_attributes %} {%- endblock button_attributes -%}

View File

@ -1,6 +1,6 @@
{% use "form_div_layout.html.twig" %} {% use "form_div_layout.html.twig" %}
{% block form_row -%} {%- block form_row -%}
<tr> <tr>
<td> <td>
{{- form_label(form) -}} {{- form_label(form) -}}
@ -10,26 +10,26 @@
{{- form_widget(form) -}} {{- form_widget(form) -}}
</td> </td>
</tr> </tr>
{%- endblock form_row %} {%- endblock form_row -%}
{% block button_row -%} {%- block button_row -%}
<tr> <tr>
<td></td> <td></td>
<td> <td>
{{- form_widget(form) -}} {{- form_widget(form) -}}
</td> </td>
</tr> </tr>
{% endblock button_row %} {%- endblock button_row -%}
{% block hidden_row -%} {%- block hidden_row -%}
<tr style="display: none"> <tr style="display: none">
<td colspan="2"> <td colspan="2">
{{- form_widget(form) -}} {{- form_widget(form) -}}
</td> </td>
</tr> </tr>
{% endblock hidden_row %} {%- endblock hidden_row -%}
{% block form_widget_compound -%} {%- block form_widget_compound -%}
<table {{ block('widget_container_attributes') }}> <table {{ block('widget_container_attributes') }}>
{%- if form.parent is empty and errors|length > 0 -%} {%- if form.parent is empty and errors|length > 0 -%}
<tr> <tr>
@ -37,8 +37,8 @@
{{- form_errors(form) -}} {{- form_errors(form) -}}
</td> </td>
</tr> </tr>
{%- endif %} {%- endif -%}
{{- block('form_rows') -}} {{- block('form_rows') -}}
{{- form_rest(form) -}} {{- form_rest(form) -}}
</table> </table>
{%- endblock form_widget_compound %} {%- endblock form_widget_compound -%}

View File

@ -159,6 +159,7 @@
<xsd:complexType name="translator"> <xsd:complexType name="translator">
<xsd:attribute name="enabled" type="xsd:boolean" /> <xsd:attribute name="enabled" type="xsd:boolean" />
<xsd:attribute name="fallback" type="xsd:string" /> <xsd:attribute name="fallback" type="xsd:string" />
<xsd:attribute name="logging" type="xsd:boolean" />
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="validation"> <xsd:complexType name="validation">

View File

@ -44,7 +44,7 @@
<framework:resource>theme2</framework:resource> <framework:resource>theme2</framework:resource>
</framework:form> </framework:form>
</framework:templating> </framework:templating>
<framework:translator enabled="true" fallback="fr" /> <framework:translator enabled="true" fallback="fr" logging="true" />
<framework:validation enabled="true" cache="apc" /> <framework:validation enabled="true" cache="apc" />
<framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" /> <framework:annotations cache="file" debug="true" file-cache-dir="%kernel.cache_dir%/annotations" />
</framework:config> </framework:config>

View File

@ -59,7 +59,7 @@ class XmlReferenceDumper
}); });
if (count($remapping)) { if (count($remapping)) {
list($singular, $plural) = current($remapping); list($singular) = current($remapping);
$rootName = $singular; $rootName = $singular;
} }
} }

View File

@ -14,7 +14,6 @@ namespace Symfony\Component\Config\Definition\Dumper;
use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\NodeInterface; use Symfony\Component\Config\Definition\NodeInterface;
use Symfony\Component\Config\Definition\ArrayNode; use Symfony\Component\Config\Definition\ArrayNode;
use Symfony\Component\Config\Definition\ScalarNode;
use Symfony\Component\Config\Definition\EnumNode; use Symfony\Component\Config\Definition\EnumNode;
use Symfony\Component\Config\Definition\PrototypedArrayNode; use Symfony\Component\Config\Definition\PrototypedArrayNode;
use Symfony\Component\Yaml\Inline; use Symfony\Component\Yaml\Inline;

View File

@ -460,10 +460,10 @@ class Application
{ {
$namespaces = array(); $namespaces = array();
foreach ($this->commands as $command) { foreach ($this->commands as $command) {
$namespaces[] = $this->extractNamespace($command->getName()); $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
foreach ($command->getAliases() as $alias) { 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(); $trace = $e->getTrace();
array_unshift($trace, array( array_unshift($trace, array(
'function' => '', 'function' => '',
'file' => $e->getFile() != null ? $e->getFile() : 'n/a', 'file' => $e->getFile() !== null ? $e->getFile() : 'n/a',
'line' => $e->getLine() != null ? $e->getLine() : 'n/a', 'line' => $e->getLine() !== null ? $e->getLine() : 'n/a',
'args' => array(), 'args' => array(),
)); ));
@ -1150,4 +1150,28 @@ class Application
return $lines; 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;
}
} }

View File

@ -105,7 +105,7 @@ class MarkdownDescriptor extends Descriptor
$this->write($help); $this->write($help);
} }
if ($definition = $command->getNativeDefinition()) { if ($command->getNativeDefinition()) {
$this->write("\n\n"); $this->write("\n\n");
$this->describeInputDefinition($command->getNativeDefinition()); $this->describeInputDefinition($command->getNativeDefinition());
} }

View File

@ -42,14 +42,14 @@ class CommandTester
/** /**
* Executes the command. * Executes the command.
* *
* Available options: * Available execution options:
* *
* * interactive: Sets the input interactive flag * * interactive: Sets the input interactive flag
* * decorated: Sets the output decorated flag * * decorated: Sets the output decorated flag
* * verbosity: Sets the output verbosity flag * * verbosity: Sets the output verbosity flag
* *
* @param array $input An array of arguments and options * @param array $input An array of command arguments and options
* @param array $options An array of options * @param array $options An array of execution options
* *
* @return int The command exit code * @return int The command exit code
*/ */

View File

@ -45,6 +45,8 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
require_once self::$fixturesPath.'/Foo5Command.php'; require_once self::$fixturesPath.'/Foo5Command.php';
require_once self::$fixturesPath.'/FoobarCommand.php'; require_once self::$fixturesPath.'/FoobarCommand.php';
require_once self::$fixturesPath.'/BarBucCommand.php'; require_once self::$fixturesPath.'/BarBucCommand.php';
require_once self::$fixturesPath.'/FooSubnamespaced1Command.php';
require_once self::$fixturesPath.'/FooSubnamespaced2Command.php';
} }
protected function normalizeLineBreaks($text) 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'); $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 * @expectedException \InvalidArgumentException
* @expectedExceptionMessage The namespace "f" is ambiguous (foo, foo1). * @expectedExceptionMessage The namespace "f" is ambiguous (foo, foo1).

View File

@ -0,0 +1,26 @@
<?php
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class FooSubnamespaced1Command extends Command
{
public $input;
public $output;
protected function configure()
{
$this
->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;
}
}

View File

@ -0,0 +1,26 @@
<?php
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class FooSubnamespaced2Command extends Command
{
public $input;
public $output;
protected function configure()
{
$this
->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;
}
}

View File

@ -50,7 +50,7 @@ class ExceptionHandler
*/ */
public static function register($debug = true, $fileLinkFormat = null) 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')); $prev = set_exception_handler(array($handler, 'handle'));
if (is_array($prev) && $prev[0] instanceof ErrorHandler) { if (is_array($prev) && $prev[0] instanceof ErrorHandler) {

View File

@ -26,7 +26,6 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
*/ */
class CheckCircularReferencesPass implements CompilerPassInterface class CheckCircularReferencesPass implements CompilerPassInterface
{ {
private $currentId;
private $currentPath; private $currentPath;
private $checkedNodes; private $checkedNodes;
@ -41,7 +40,6 @@ class CheckCircularReferencesPass implements CompilerPassInterface
$this->checkedNodes = array(); $this->checkedNodes = array();
foreach ($graph->getNodes() as $id => $node) { foreach ($graph->getNodes() as $id => $node) {
$this->currentId = $id;
$this->currentPath = array($id); $this->currentPath = array($id);
$this->checkOutEdges($node->getOutEdges()); $this->checkOutEdges($node->getOutEdges());

View File

@ -33,7 +33,6 @@ class CheckReferenceValidityPass implements CompilerPassInterface
{ {
private $container; private $container;
private $currentId; private $currentId;
private $currentDefinition;
private $currentScope; private $currentScope;
private $currentScopeAncestors; private $currentScopeAncestors;
private $currentScopeChildren; private $currentScopeChildren;

View File

@ -120,7 +120,11 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
} }
if (!$this->guessers) { 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) { foreach ($this->guessers as $guesser) {

View File

@ -480,7 +480,7 @@ class Request
} }
if (!$dup->getRequestFormat(null)) { if (!$dup->getRequestFormat(null)) {
$dup->setRequestFormat($format = $this->getRequestFormat(null)); $dup->setRequestFormat($this->getRequestFormat(null));
} }
return $dup; return $dup;

View File

@ -0,0 +1,95 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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 <chriswilkinson84@gmail.com>
*/
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;
}
}

View File

@ -24,7 +24,7 @@ use Symfony\Component\VarDumper\VarDumper;
*/ */
class DumpListener implements EventSubscriberInterface class DumpListener implements EventSubscriberInterface
{ {
private $container; private $cloner;
private $dumper; private $dumper;
/** /**

View File

@ -25,6 +25,7 @@ use Symfony\Component\DependencyInjection\Loader\ClosureLoader;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\Config\EnvParametersResource;
use Symfony\Component\HttpKernel\Config\FileLocator; use Symfony\Component\HttpKernel\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass; use Symfony\Component\HttpKernel\DependencyInjection\AddClassesToCachePass;
@ -630,6 +631,7 @@ abstract class Kernel implements KernelInterface, TerminableInterface
} }
$container->addCompilerPass(new AddClassesToCachePass($this)); $container->addCompilerPass(new AddClassesToCachePass($this));
$container->addResource(new EnvParametersResource('SYMFONY__'));
return $container; return $container;
} }

View File

@ -0,0 +1,106 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* 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)));
}
}

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\HttpKernel\Tests; namespace Symfony\Component\HttpKernel\Tests;
use Symfony\Component\HttpKernel\Config\EnvParametersResource;
use Symfony\Component\HttpKernel\Kernel; use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -111,6 +112,35 @@ class KernelTest extends \PHPUnit_Framework_TestCase
->method('doLoadClassCache'); ->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() public function testBootKernelSeveralTimesOnlyInitializesBundlesOnce()
{ {
$kernel = $this->getKernel(array('initializeBundles', 'initializeContainer')); $kernel = $this->getKernel(array('initializeBundles', 'initializeContainer'));

View File

@ -264,20 +264,6 @@ final class Intl
return self::$entryReader; 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. * This class must not be instantiated.
*/ */

View File

@ -172,7 +172,7 @@ class UnixPipes extends AbstractPipes
} }
if (null !== $w && 0 < count($w)) { 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 $written = fwrite($w[0], $this->inputBuffer, 2 << 18); // write 512k
if ($written > 0) { if ($written > 0) {
$this->inputBuffer = (string) substr($this->inputBuffer, $written); $this->inputBuffer = (string) substr($this->inputBuffer, $written);

View File

@ -235,7 +235,7 @@ class WindowsPipes extends AbstractPipes
} }
if (null !== $w && 0 < count($w)) { if (null !== $w && 0 < count($w)) {
while ($len = strlen($this->inputBuffer)) { while (strlen($this->inputBuffer)) {
$written = fwrite($w[0], $this->inputBuffer, 2 << 18); $written = fwrite($w[0], $this->inputBuffer, 2 << 18);
if ($written > 0) { if ($written > 0) {
$this->inputBuffer = (string) substr($this->inputBuffer, $written); $this->inputBuffer = (string) substr($this->inputBuffer, $written);

View File

@ -1295,8 +1295,7 @@ class Process
{ {
$that = $this; $that = $this;
$out = self::OUT; $out = self::OUT;
$err = self::ERR; $callback = function ($type, $data) use ($that, $callback, $out) {
$callback = function ($type, $data) use ($that, $callback, $out, $err) {
if ($out == $type) { if ($out == $type) {
$that->addOutput($data); $that->addOutput($data);
} else { } else {

View File

@ -579,8 +579,6 @@ class PropertyAccessor implements PropertyAccessorInterface
*/ */
private function findAdderAndRemover(\ReflectionClass $reflClass, array $singulars) private function findAdderAndRemover(\ReflectionClass $reflClass, array $singulars)
{ {
$exception = null;
foreach ($singulars as $singular) { foreach ($singulars as $singular) {
$addMethod = 'add'.$singular; $addMethod = 'add'.$singular;
$removeMethod = 'remove'.$singular; $removeMethod = 'remove'.$singular;

View File

@ -109,8 +109,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface
$element = $matches[3]; $element = $matches[3];
$this->isIndex[] = true; $this->isIndex[] = true;
} }
// Disabled this behaviour as the syntax is not yet final
//$pos = strpos($element, self::SINGULAR_SEPARATOR);
$pos = false; $pos = false;
$singular = null; $singular = null;

View File

@ -853,7 +853,6 @@ QUERY;
{ {
$sids = new \SplObjectStorage(); $sids = new \SplObjectStorage();
$classIds = new \SplObjectStorage(); $classIds = new \SplObjectStorage();
$currentIds = array();
foreach ($changes[1] as $field => $new) { foreach ($changes[1] as $field => $new) {
for ($i = 0, $c = count($new); $i<$c; $i++) { for ($i = 0, $c = count($new); $i<$c; $i++) {
$ace = $new[$i]; $ace = $new[$i];
@ -881,8 +880,6 @@ QUERY;
$aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id'); $aceIdProperty = new \ReflectionProperty('Symfony\Component\Security\Acl\Domain\Entry', 'id');
$aceIdProperty->setAccessible(true); $aceIdProperty->setAccessible(true);
$aceIdProperty->setValue($ace, intval($aceId)); $aceIdProperty->setValue($ace, intval($aceId));
} else {
$currentIds[$ace->getId()] = true;
} }
} }
} }
@ -931,7 +928,6 @@ QUERY;
$sids = new \SplObjectStorage(); $sids = new \SplObjectStorage();
$classIds = new \SplObjectStorage(); $classIds = new \SplObjectStorage();
$currentIds = array();
for ($i = 0, $c = count($new); $i<$c; $i++) { for ($i = 0, $c = count($new); $i<$c; $i++) {
$ace = $new[$i]; $ace = $new[$i];
@ -958,8 +954,6 @@ QUERY;
$aceIdProperty = new \ReflectionProperty($ace, 'id'); $aceIdProperty = new \ReflectionProperty($ace, 'id');
$aceIdProperty->setAccessible(true); $aceIdProperty->setAccessible(true);
$aceIdProperty->setValue($ace, intval($aceId)); $aceIdProperty->setValue($ace, intval($aceId));
} else {
$currentIds[$ace->getId()] = true;
} }
} }
} }

View File

@ -59,11 +59,7 @@ class PreAuthenticatedAuthenticationProvider implements AuthenticationProviderIn
if (!$user = $token->getUser()) { if (!$user = $token->getUser()) {
throw new BadCredentialsException('No pre-authenticated principal found in request.'); 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); $user = $this->userProvider->loadUserByUsername($user);
$this->userChecker->checkPostAuth($user); $this->userChecker->checkPostAuth($user);

View File

@ -55,7 +55,7 @@ class AccessListener implements ListenerInterface
$request = $event->getRequest(); $request = $event->getRequest();
list($attributes, $channel) = $this->map->getPatterns($request); list($attributes) = $this->map->getPatterns($request);
if (null === $attributes) { if (null === $attributes) {
return; return;

View File

@ -94,7 +94,7 @@ class ExceptionListener
} elseif ($exception instanceof AccessDeniedException) { } elseif ($exception instanceof AccessDeniedException) {
return $this->handleAccessDeniedException($event, $exception); return $this->handleAccessDeniedException($event, $exception);
} elseif ($exception instanceof LogoutException) { } elseif ($exception instanceof LogoutException) {
return $this->handleLogoutException($event, $exception); return $this->handleLogoutException($exception);
} }
} while (null !== $exception = $exception->getPrevious()); } 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) { if (null !== $this->logger) {
$this->logger->info('A LogoutException was thrown.', array('exception' => $exception)); $this->logger->info('A LogoutException was thrown.', array('exception' => $exception));

View File

@ -73,7 +73,7 @@ class PersistentTokenBasedRememberMeServices extends AbstractRememberMeServices
if (null !== ($cookie = $request->cookies->get($this->options['name'])) if (null !== ($cookie = $request->cookies->get($this->options['name']))
&& count($parts = $this->decodeCookie($cookie)) === 2 && count($parts = $this->decodeCookie($cookie)) === 2
) { ) {
list($series, $tokenValue) = $parts; list($series) = $parts;
$this->tokenProvider->deleteTokenBySeries($series); $this->tokenProvider->deleteTokenBySeries($series);
} }
} }

View File

@ -47,7 +47,7 @@ class IsbnValidator extends ConstraintValidator
$value = (string) $value; $value = (string) $value;
$canonical = str_replace('-', '', $value); $canonical = str_replace('-', '', $value);
if (null == $constraint->type) { if (null === $constraint->type) {
if ($constraint->isbn10 && !$constraint->isbn13) { 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); 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'; $constraint->type = 'isbn10';

View File

@ -42,11 +42,6 @@ class LegacyConstraintViolationBuilder implements ConstraintViolationBuilderInte
*/ */
private $parameters; private $parameters;
/**
* @var mixed
*/
private $root;
/** /**
* @var mixed * @var mixed
*/ */
@ -72,7 +67,6 @@ class LegacyConstraintViolationBuilder implements ConstraintViolationBuilderInte
$this->context = $context; $this->context = $context;
$this->message = $message; $this->message = $message;
$this->parameters = $parameters; $this->parameters = $parameters;
$this->root = $context->getRoot();
$this->invalidValue = $context->getValue(); $this->invalidValue = $context->getValue();
} }

View File

@ -115,8 +115,6 @@ class DOMCaster
public static function castNameSpaceNode(\DOMNameSpaceNode $dom, array $a, Stub $stub, $isNested) 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( $a += array(
'nodeName' => $dom->nodeName, 'nodeName' => $dom->nodeName,
'nodeValue' => new CutStub($dom->nodeValue), 'nodeValue' => new CutStub($dom->nodeValue),

View File

@ -98,7 +98,6 @@ class Parser
$data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport, $objectForMap); $data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport, $objectForMap);
} else { } else {
if (isset($values['leadspaces']) if (isset($values['leadspaces'])
&& ' ' == $values['leadspaces']
&& preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches) && preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $values['value'], $matches)
) { ) {
// this is a compact notation element, add to next block and parse // this is a compact notation element, add to next block and parse
@ -108,7 +107,7 @@ class Parser
$block = $values['value']; $block = $values['value'];
if ($this->isNextLineIndented()) { 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); $data[] = $parser->parse($block, $exceptionOnInvalidType, $objectSupport, $objectForMap);
@ -349,7 +348,14 @@ class Parser
$newIndent = $indentation; $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]) { 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 // 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); $removeComments = !preg_match($removeCommentsPattern, $this->currentLine);
} }
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) { if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine) && $newIndent === $indent) {
$this->moveToPreviousLine(); $this->moveToPreviousLine();
break; break;
} }

View File

@ -60,3 +60,23 @@ yaml: |
foo: bar foo: bar
php: | php: |
array('collection' => array('key' => array('a', 'b', 'c'), 'foo' => 'bar')) 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')))

View File

@ -475,6 +475,22 @@ collection:
-item2 -item2
-item3 -item3
EOF;
$this->parser->parse($yaml);
}
/**
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
*/
public function testShortcutKeyUnindentedCollectionException()
{
$yaml = <<<EOF
collection:
- key: foo
foo: bar
EOF; EOF;
$this->parser->parse($yaml); $this->parser->parse($yaml);