10000 Merge branch '2.8' into 3.3 · symfony/symfony@b4afeb2 · GitHub
[go: up one dir, main page]

Skip to content

Commit b4afeb2

Browse files
committed
Merge branch '2.8' into 3.3
* 2.8: Test that it do not remove the new flashes when displaying the existing ones [HttpFoundation] AutExpireFlashBag should not clear new flashes [Form] Don't rely on if http-foundation isn't in FileType Fix merge substitute aliases in inline mappings added ability for substitute aliases when mapping in YAML is on single line [Console] Fix global console flag when used in chain
2 parents 85223d3 + 1941a78 commit b4afeb2

File tree

8 files changed

+82
-20
lines changed
  • Yaml
  • 8 files changed

    +82
    -20
    lines changed

    src/Symfony/Component/Console/Input/ArgvInput.php

    Lines changed: 8 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -285,6 +285,14 @@ public function hasParameterOption($values, $onlyParams = false)
    285285
    if ($token === $value || 0 === strpos($token, $value.'=')) {
    286286
    return true;
    287287
    }
    288+
    289+
    if (0 === strpos($token, '-') && 0 !== strpos($token, '--')) {
    290+
    $searchableToken = str_replace('-', '', $token);
    291+
    $searchableValue = str_replace('-', '', $value);
    292+
    if ('' !== $searchableToken && '' !== $searchableValue && false !== strpos($searchableToken, $searchableValue)) {
    293+
    return true;
    294+
    }
    295+
    }
    288296
    }
    289297
    }
    290298

    src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

    Lines changed: 3 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -314,6 +314,9 @@ public function testHasParameterOption()
    314314
    $input = new ArgvInput(array('cli.php', '-f', 'foo'));
    315315
    $this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input');
    316316

    317+
    $input = new ArgvInput(array('cli.php', '-fh'));
    318+
    $this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
    319+
    317320
    $input = new ArgvInput(array('cli.php', '--foo', 'foo'));
    318321
    $this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');
    319322

    src/Symfony/Component/Form/Extension/Core/Type/FileType.php

    Lines changed: 6 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -92,9 +92,12 @@ public function finishView(FormView $view, FormInterface $form, array $options)
    9292
    */
    9393
    public function configureOptions(OptionsResolver $resolver)
    9494
    {
    95-
    $dataClass = function (Options $options) {
    96-
    return $options['multiple'] ? null : 'Symfony\Component\HttpFoundation\File\File';
    97-
    };
    95+
    $dataClass = null;
    96+
    if (class_exists('Symfony\Component\HttpFoundation\File\File')) {
    97+
    $dataClass = function (Options $options) {
    98+
    return $options['multiple'] ? null : 'Sy 57A6 mfony\Component\HttpFoundation\File\File';
    99+
    };
    100+
    }
    98101

    99102
    $emptyData = function (Options $options) {
    100103
    return $options['multiple'] ? array() : null;

    src/Symfony/Component/HttpFoundation/Session/Flash/AutoExpireFlashBag.php

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -106,7 +106,7 @@ public function get($type, array $default = array())
    106106
    public function all()
    107107
    {
    108108
    $return = $this->flashes['display'];
    109-
    $this->flashes = array('new' => array(), 'display' => array());
    109+
    $this->flashes['display'] = array();
    110110

    111111
    return $return;
    112112
    }

    src/Symfony/Component/HttpFoundation/Tests/Session/Flash/AutoExpireFlashBagTest.php

    Lines changed: 8 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -150,4 +150,12 @@ public function testClear()
    150150
    {
    151151
    $this->assertEquals(array('notice' => array('A previous flash message')), $this->bag->clear());
    152152
    }
    153+
    154+
    public function testDoNotRemoveTheNewFlashesWhenDisplayingTheExistingOnes()
    155+
    {
    156+
    $this->bag->add('success', 'Something');
    157+
    $this->bag->all();
    158+
    159+
    $this->assertEquals(array('new' => array('success' => array('Something')), 'display' => array()), $this->array);
    160+
    }
    153161
    }

    src/Symfony/Component/Yaml/Inline.php

    Lines changed: 37 additions & 15 deletions
    Original file line numberDiff line numberDiff line change
    @@ -462,6 +462,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
    462462
    $output = array();
    463463
    $len = strlen($mapping);
    464464
    ++$i;
    465+
    $allowOverwrite = false;
    465466

    466467
    // {foo: bar, bar:foo, ...}
    467468
    while ($i < $len) {
    @@ -502,6 +503,10 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
    502503
    @trigger_error(sprintf('Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since version 3.2 and will throw a ParseException in 4.0 on line %d.', self::$parsedLineNumber + 1), E_USER_DEPRECATED);
    503504
    }
    504505

    506+
    if ('<<' === $key) {
    507+
    $allowOverwrite = true;
    508+
    }
    509+
    505510
    while ($i < $len) {
    506511
    if (':' === $mapping[$i] || ' ' === $mapping[$i]) {
    507512
    ++$i;
    @@ -510,17 +515,26 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
    510515
    }
    511516

    512517
    $tag = self::parseTag($mapping, $i, $flags);
    513-
    $duplicate = false;
    514518
    switch ($mapping[$i]) {
    515519
    case '[':
    516520
    // nested sequence
    517521
    $value = self::parseSequence($mapping, $flags, $i, $references);
    518522
    // Spec: Keys MUST be unique; first one wins.
    519523
    // Parser cannot abort this mapping earlier, since lines
    520524
    // are processed sequentially.
    521-
    if (isset($output[$key])) {
    525+
    // But overwriting is allowed when a merge node is used in current block.
    526+
    if ('<<' === $key) {
    527+
    foreach ($value as $parsedValue) {
    528+
    $output += $parsedValue;
    529+
    }
    530+
    } elseif ($allowOverwrite || !isset($output[$key])) {
    531+
    if (null !== $tag) {
    532+
    $output[$key] = new TaggedValue($tag, $value);
    533+
    } else {
    534+
    $output[$key] = $value;
    535+
    }
    536+
    } elseif (isset($output[$key])) {
    522537
    @trigger_error(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line %d.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
    523-
    $duplicate = true;
    524538
    }
    525539
    break;
    526540
    case '{':
    @@ -529,30 +543,38 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
    529543
    // Spec: Keys MUST be unique; first one wins.
    530544
    // Parser cannot abort this mapping earlier, since lines
    531545
    // are processed sequentially.
    532-
    if (isset($output[$key])) {
    546+
    // But overwriting is allowed when a merge node is used in current block.
    547+
    if ('<<' === $key) {
    548+
    $output += $value;
    549+
    } elseif ($allowOverwrite || !isset($output[$key])) {
    550+
    if (null !== $tag) {
    551+
    $output[$key] = new TaggedValue($tag, $value);
    552+
    } else {
    553+
    $output[$key] = $value;
    554+
    }
    555+
    } elseif (isset($output[$key])) {
    533556
    @trigger_error(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line %d.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
    534-
    $duplicate = true;
    535557
    }
    536558
    break;
    537559
    default:
    538560
    $value = self::parseScalar($mapping, $flags, array(',', '}'), $i, null === $tag, $references);
    539561
    // Spec: Keys MUST be unique; first one wins.
    540562
    // Parser cannot abort this mapping earlier, since lines
    541563
    // are processed sequentially.
    542-
    if (isset($output[$key])) {
    564+
    // But overwriting is allowed when a merge node is used in current block.
    565+
    if ('<<' === $key) {
    566+
    $output += $value;
    567+
    } elseif ($allowOverwrite || !isset($output[$key])) {
    568+
    if (null !== $tag) {
    569+
    $output[$key] = new TaggedValue($tag, $value);
    570+
    } else {
    571+
    $output[$key] = $value;
    572+
    }
    573+
    } elseif (isset($output[$key])) {
    543574
    @trigger_error(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since version 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line %d.', $key, self::$parsedLineNumber + 1), E_USER_DEPRECATED);
    544-
    $duplicate = true;
    545575
    }
    546576
    --$i;
    547577
    }
    548-
    549-
    if (!$duplicate) {
    550-
    if (null !== $tag) {
    551-
    $output[$key] = new TaggedValue($tag, $value);
    552-
    } else {
    553-
    $output[$key] = $value;
    554-
    }
    555-
    }
    556578
    ++$i;
    557579

    558580
    continue 2;

    src/Symfony/Component/Yaml/Tests/Fixtures/sfMergeKey.yml

    Lines changed: 7 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -21,6 +21,7 @@ yaml: |
    2121
    c:
    2222
    foo: bar
    2323
    bar: foo
    24+
    bar_inline: {a: before, d: other, <<: *foo, b: new, x: Oren, c: { foo: bar, bar: foo}}
    2425
    foo2: &foo2
    2526
    a: Ballmer
    2627
    ding: &dong [ fi, fei, fo, fam]
    @@ -42,14 +43,19 @@ yaml: |
    4243
    p: 12345
    4344
    z:
    4445
    <<: *nestedref
    46+
    head_inline: &head_inline { <<: [ *foo , *dong , *foo2 ] }
    47+
    recursive_inline: { <<: *head_inline, c: { <<: *foo2 } }
    4548
    php: |
    4649
    array(
    4750
    'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull'),
    4851
    'bar' => array('a' => 'before', 'd' => 'other', 'e' => null, 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'),
    52+
    'bar_inline' => array('a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'e' => 'notnull', 'x' => 'Oren'),
    4953
    'foo2' => array('a' => 'Ballmer'),
    5054
    'ding' => array('fi', 'fei', 'fo', 'fam'),
    5155
    'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'),
    5256
    'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
    5357
    'taz' => array('a' => 'Steve', 'w' => array('p' => 1234)),
    54-
    'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345))
    58+
    'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345)),
    59+
    'head_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
    60+
    'recursive_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => array('a' => 'Ballmer'), 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
    5561
    )

    src/Symfony/Component/Yaml/Tests/ParserTest.php

    Lines changed: 12 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1969,6 +1969,18 @@ public function testParseReferencesOnMergeKeysWithMappingsParsedAsObjects()
    19691969

    19701970
    $this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
    19711971
    }
    1972+
    1973+
    /**
    1974+
    * @expectedException \Symfony\Component\Yaml\Exception\ParseException
    1975+
    * @expectedExceptionMessage Reference "foo" does not exist
    1976+
    */
    1977+
    public function testEvalRefException()
    1978+
    {
    1979+
    $yaml = <<<EOE
    1980+
    foo: { &foo { a: Steve, <<: *foo} }
    1981+
    EOE;
    1982+
    $this->parser->parse($yaml);
    1983+
    }
    19721984
    }
    19731985

    19741986
    class B

    0 commit comments

    Comments
     (0)
    0