8000 Merge branch '2.7' into 2.8 · symfony/symfony@1941a78 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1941a78

Browse files
Merge branch '2.7' into 2.8
* 2.7: 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 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 37baa1d + e2c608a commit 1941a78

File tree

8 files changed

+64
-8
lines changed

8 files changed

+64
-8
lines changed

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

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

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

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

299+
$input = new ArgvInput(array('cli.php', '-fh'));
300+
$this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
301+
299302
$input = new ArgvInput(array('cli.php', '--foo', 'foo'));
300303
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');
301304

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 : 'Symfony\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();
9E88 158+
159+
$this->assertEquals(array('new' => array('success' => array('Something')), 'display' => array()), $this->array);
160+
}
153161
}

src/Symfony/Component/Yaml/Inline.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ private static function parseMapping($mapping, &$i = 0, $references = array())
375375
$output = array();
376376
$len = strlen($mapping);
377377
++$i;
378+
$allowOverwrite = false;
378379

379380
// {foo: bar, bar:foo, ...}
380381
while ($i < $len) {
@@ -394,6 +395,10 @@ private static function parseMapping($mapping, &$i = 0, $references = array())
394395
// key
395396
$key = self::parseScalar($mapping, array(':', ' '), array('"', "'"), $i, false);
396397

398+
if ('<<' === $key) {
399+
$allowOverwrite = true;
400+
}
401+
397402
// value
398403
$done = false;
399404

@@ -405,7 +410,12 @@ private static function parseMapping($mapping, &$i = 0, $references = array())
405410
// Spec: Keys MUST be unique; first one wins.
406411
// Parser cannot abort this mapping earlier, since lines
407412
// are processed sequentially.
408-
if (!isset($output[$key])) {
413+
// But overwriting is allowed when a merge node is used in current block.
414+
if ('<<' === $key) {
415+
foreach ($value as $parsedValue) {
416+
$output += $parsedValue;
417+
}
418+
} elseif ($allowOverwrite || !isset($output[$key])) {
409419
$output[$key] = $value;
410420
}
411421
$done = true;
@@ -416,7 +426,10 @@ private static function parseMapping($mapping, &$i = 0, $references = array())
416426
// Spec: Keys MUST be unique; first one wins.
417427
// Parser cannot abort this mapping earlier, since lines
418428
// are processed sequentially.
419-
if (!isset($output[$key])) {
429+
// But overwriting is allowed when a merge node is used in current block.
430+
if ('<<' === $key) {
431+
$output += $value;
432+
} elseif ($allowOverwrite || !isset($output[$key])) {
420433
$output[$key] = $value;
421434
}
422435
$done = true;
@@ -429,7 +442,10 @@ private static function parseMapping($mapping, &$i = 0, $references = array())
429442
// Spec: Keys MUST be unique; first one wins.
430443
// Parser cannot abort this mapping earlier, since lines
431444
// are processed sequentially.
432-
if (!isset($output[$key])) {
445+
// But overwriting is allowed when a merge node is used in current block.
446+
if ('<<' === $key) {
447+
$output += $value;
448+
} elseif ($allowOverwrite || !isset($output[$key])) {
433449
$output[$key] = $value;
434450
}
435451
$done = true;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ yaml: |
2222
foo: bar
2323
foo: ignore
2424
bar: foo
25+
bar_inline: {a: before, d: other, <<: *foo, b: new, x: Oren, c: { foo: bar, foo: ignore, bar: foo}}
2526
duplicate:
2627
foo: bar
2728
foo: ignore
@@ -46,15 +47,20 @@ yaml: |
4647
p: 12345
4748
z:
4849
<<: *nestedref
50+
head_inline: &head_inline { <<: [ *foo , *dong , *foo2 ] }
51+
recursive_inline: { <<: *head_inline, c: { <<: *foo2 } }
4952
php: |
5053
array(
5154
'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull'),
5255
'bar' => array('a' => 'before', 'd' => 'other', 'e' => null, 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'),
56+
'bar_inline' => array('a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'e' => 'notnull', 'x' => 'Oren'),
5357
'duplicate' => array('foo' => 'bar'),
5458
'foo2' => array('a' => 'Ballmer'),
5559
'ding' => array('fi', 'fei', 'fo', 'fam'),
5660
'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'),
5761
'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
5862
'taz' => array('a' => 'Steve', 'w' => array('p' => 1234)),
59-
'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345))
63+
'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345)),
64+
'head_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
65+
'recursive_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => array('a' => 'Ballmer'), 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
6066
)

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,18 @@ public function testParseReferencesOnMergeKeys()
12801280

12811281
$this->assertSame($expected, $this->parser->parse($yaml));
12821282
}
1283+
1284+
/**
1285+
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
1286+
* @expectedExceptionMessage Reference "foo" does not exist
1287+
*/
1288+
public function testEvalRefException()
1289+
{
1290+
$yaml = <<<EOE
1291+
foo: { &foo { a: Steve, <<: *foo} }
1292+
EOE;
1293+
$this->parser->parse($yaml);
1294+
}
12831295
}
12841296

12851297
class B

0 commit comments

Comments
 (0)
0