Skip to content

Commit 9f95e4a

Browse files
Merge branch '2.8' into 3.1
* 2.8: CS fixes Remove trailing space CS: apply rules [Yaml] Clean some messages + add test case [Console] simplified code [Form] Fix UrlType transforms valid protocols [SecurityBundle] Changed encoder configuration example to bcrypt
2 parents 7ff51b0 + 58666e4 commit 9f95e4a

File tree

3 files changed

+45
-36
lines changed

3 files changed

+45
-36
lines changed

Inline.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, $str
308308
$output = $match[1];
309309
$i += strlen($output);
310310
} else {
311-
throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
311+
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar));
312312
}
313313

314314
// a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
@@ -341,7 +341,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, $str
341341
private static function parseQuotedScalar($scalar, &$i)
342342
{
343343
if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
344-
throw new ParseException(sprintf('Malformed inline YAML string (%s).', substr($scalar, $i)));
344+
throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)));
345345
}
346346

347347
$output = substr($match[0], 1, strlen($match[0]) - 2);
@@ -415,7 +415,7 @@ private static function parseSequence($sequence, $flags, &$i = 0, $references =
415415
++$i;
416416
}
417417

418-
throw new ParseException(sprintf('Malformed inline YAML string %s', $sequence));
418+
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence));
419419
}
420420

421421
/**
@@ -504,7 +504,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
504504
}
505505
}
506506

507-
throw new ParseException(sprintf('Malformed inline YAML string %s', $mapping));
507+
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping));
508508
}
509509

510510
/**

Tests/InlineTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,4 +595,13 @@ public function getInvalidBinaryData()
595595
'misplaced equals character' => array('!!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'),
596596
);
597597
}
598+
599+
/**
600+
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
601+
* @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported}.
602+
*/
603+
public function testNotSupportedMissingValue()
604+
{
605+
Inline::parse('{this, is not, supported}');
606+
}
598607
}

Tests/ParserTest.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ public function testBlockLiteralWithLeadingNewlines()
421421

422422
public function testObjectSupportEnabled()
423423
{
424-
$input = <<<EOF
424+
$input = <<<'EOF'
425425
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
426426
bar: 1
427427
EOF;
@@ -433,7 +433,7 @@ public function testObjectSupportEnabled()
433433
*/
434434
public function testObjectSupportEnabledPassingTrue()
435435
{
436-
$input = <<<EOF
436+
$input = <<<'EOF'
437437
foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
438438
bar: 1
439439
EOF;
@@ -445,7 +445,7 @@ public function testObjectSupportEnabledPassingTrue()
445445
*/
446446
public function testObjectSupportEnabledWithDeprecatedTag()
447447
{
448-
$input = <<<EOF
448+
$input = <<<'EOF'
449449
foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
450450
bar: 1
451451
EOF;
@@ -481,7 +481,7 @@ public function getObjectForMapTests()
481481
{
482482
$tests = array();
483483

484-
$yaml = <<<EOF
484+
$yaml = <<<'EOF'
485485
foo:
486486
fiz: [cat]
487487
EOF;
@@ -502,7 +502,7 @@ public function getObjectForMapTests()
502502
$expected->baz = 'foobar';
503503
$tests['object-for-map-is-applied-after-parsing'] = array($yaml, $expected);
504504

505-
$yaml = <<<EOT
505+
$yaml = <<<'EOT'
506506
array:
507507
- key: one
508508
- key: two
@@ -515,7 +515,7 @@ public function getObjectForMapTests()
515515
$expected->array[1]->key = 'two';
516516
$tests['nest-map-and-sequence'] = array($yaml, $expected);
517517

518-
$yaml = <<<YAML
518+
$yaml = <<<'YAML'
519519
map:
520520
1: one
521521
2: two
@@ -526,7 +526,7 @@ public function getObjectForMapTests()
526526
$expected->map->{2} = 'two';
527527
$tests['numeric-keys'] = array($yaml, $expected);
528528

529-
$yaml = <<<YAML
529+
$yaml = <<<'YAML'
530530
map:
531531
0: one
532532
1: two
@@ -561,11 +561,11 @@ public function testObjectsSupportDisabledWithExceptionsUsingBooleanToggles($yam
561561

562562
public function invalidDumpedObjectProvider()
563563
{
564-
$yamlTag = <<<EOF
564+
$yamlTag = <<<'EOF'
565565
foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
566566
bar: 1
567567
EOF;
568-
$localTag = <<<EOF
568+
$localTag = <<<'EOF'
569569
foo: !php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
570570
bar: 1
571571
EOF;
@@ -667,7 +667,7 @@ public function testSequenceInAMapping()
667667

668668
public function testSequenceInMappingStartedBySingleDashLine()
669669
{
670-
$yaml = <<<EOT
670+
$yaml = <<<'EOT'
671671
a:
672672
-
673673
b:
@@ -695,7 +695,7 @@ public function testSequenceInMappingStartedBySingleDashLine()
695695

696696
public function testSequenceFollowedByCommentEmbeddedInMapping()
697697
{
698-
$yaml = <<<EOT
698+
$yaml = <<<'EOT'
699699
a:
700700
b:
701701
- c
@@ -731,7 +731,7 @@ public function testMappingInASequence()
731731
*/
732732
public function testScalarInSequence()
733733
{
734-
Yaml::parse(<<<EOF
734+
Yaml::parse(<<<'EOF'
735735
foo:
736736
- bar
737737
"missing colon"
@@ -752,7 +752,7 @@ public function testScalarInSequence()
752752
*/
753753
public function testMappingDuplicateKeyBlock()
754754
{
755-
$input = <<<EOD
755+
$input = <<<'EOD'
756756
parent:
757757
child: first
758758
child: duplicate
@@ -770,7 +770,7 @@ public function testMappingDuplicateKeyBlock()
770770

771771
public function testMappingDuplicateKeyFlow()
772772
{
773-
$input = <<<EOD
773+
$input = <<<'EOD'
774774
parent: { child: first, child: duplicate }
775775
parent: { child: duplicate, child: duplicate }
776776
EOD;
@@ -967,7 +967,7 @@ public function testFloatKeys()
967967
*/
968968
public function testColonInMappingValueException()
969969
{
970-
$yaml = <<<EOF
970+
$yaml = <<<'EOF'
971971
foo: bar: baz
972972
EOF;
973973

@@ -976,7 +976,7 @@ public function testColonInMappingValueException()
976976

977977
public function testColonInMappingValueExceptionNotTriggeredByColonInComment()
978978
{
979-
$yaml = <<<EOT
979+
$yaml = <<<'EOT'
980980
foo:
981981
bar: foobar # Note: a comment after a colon
982982
EOT;
@@ -1077,7 +1077,7 @@ public function getCommentLikeStringInScalarBlockData()
10771077
);
10781078
$tests[] = array($yaml, $expected);
10791079

1080-
$yaml = <<<EOT
1080+
$yaml = <<<'EOT'
10811081
foo:
10821082
bar:
10831083
scalar-block: >
@@ -1120,7 +1120,7 @@ public function getCommentLikeStringInScalarBlockData()
11201120

11211121
public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks()
11221122
{
1123-
$yaml = <<<EOT
1123+
$yaml = <<<'EOT'
11241124
test: >
11251125
<h2>A heading</h2>
11261126
@@ -1132,7 +1132,7 @@ public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks()
11321132

11331133
$this->assertSame(
11341134
array(
1135-
'test' => <<<EOT
1135+
'test' => <<<'EOT'
11361136
<h2>A heading</h2>
11371137
<ul> <li>a list</li> <li>may be a good example</li> </ul>
11381138
EOT
@@ -1144,7 +1144,7 @@ public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks()
11441144

11451145
public function testAdditionallyIndentedLinesAreParsedAsNewLinesInFoldedBlocks()
11461146
{
1147-
$yaml = <<<EOT
1147+
$yaml = <<<'EOT'
11481148
test: >
11491149
<h2>A heading</h2>
11501150
@@ -1156,7 +1156,7 @@ public function testAdditionallyIndentedLinesAreParsedAsNewLinesInFoldedBlocks()
11561156

11571157
$this->assertSame(
11581158
array(
1159-
'test' => <<<EOT
1159+
'test' => <<<'EOT'
11601160
<h2>A heading</h2>
11611161
<ul>
11621162
<li>a list</li>
@@ -1184,13 +1184,13 @@ public function getBinaryData()
11841184
'enclosed with single quotes' => array("data: !!binary 'SGVsbG8gd29ybGQ='"),
11851185
'containing spaces' => array('data: !!binary "SGVs bG8gd 29ybGQ="'),
11861186
'in block scalar' => array(
1187-
<<<EOT
1187+
<<<'EOT'
11881188
data: !!binary |
11891189
SGVsbG8gd29ybGQ=
11901190
EOT
11911191
),
11921192
'containing spaces in block scalar' => array(
1193-
<<<EOT
1193+
<<<'EOT'
11941194
data: !!binary |
11951195
SGVs bG8gd 29ybGQ=
11961196
EOT
@@ -1216,31 +1216,31 @@ public function getInvalidBinaryData()
12161216
'too many equals characters' => array('data: !!binary "SGVsbG8gd29yb==="', '/The base64 encoded data \(.*\) contains invalid characters/'),
12171217
'misplaced equals character' => array('data: !!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'),
12181218
'length not a multiple of four in block scalar' => array(
1219-
<<<EOT
1219+
<<<'EOT'
12201220
data: !!binary |
12211221
SGVsbG8d29ybGQ=
12221222
EOT
12231223
,
12241224
'/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/',
12251225
),
12261226
'invalid characters in block scalar' => array(
1227-
<<<EOT
1227+
<<<'EOT'
12281228
data: !!binary |
12291229
SGVsbG8#d29ybGQ=
12301230
EOT
12311231
,
12321232
'/The base64 encoded data \(.*\) contains invalid characters/',
12331233
),
12341234
'too many equals characters in block scalar' => array(
1235-
<<<EOT
1235+
<<<'EOT'
12361236
data: !!binary |
12371237
SGVsbG8gd29yb===
12381238
EOT
12391239
,
12401240
'/The base64 encoded data \(.*\) contains invalid characters/',
12411241
),
12421242
'misplaced equals character in block scalar' => array(
1243-
<<<EOT
1243+
<<<'EOT'
12441244
data: !!binary |
12451245
SGVsbG8gd29ybG=Q
12461246
EOT
@@ -1252,7 +1252,7 @@ public function getInvalidBinaryData()
12521252

12531253
public function testParseDateAsMappingValue()
12541254
{
1255-
$yaml = <<<EOT
1255+
$yaml = <<<'EOT'
12561256
date: 2002-12-14
12571257
EOT;
12581258
$expectedDate = new \DateTime();
@@ -1283,7 +1283,7 @@ public function parserThrowsExceptionWithCorrectLineNumberProvider()
12831283
return array(
12841284
array(
12851285
4,
1286-
<<<YAML
1286+
<<<'YAML'
12871287
foo:
12881288
-
12891289
# bar
@@ -1292,7 +1292,7 @@ public function parserThrowsExceptionWithCorrectLineNumberProvider()
12921292
),
12931293
array(
12941294
5,
1295-
<<<YAML
1295+
<<<'YAML'
12961296
foo:
12971297
-
12981298
# bar
@@ -1302,7 +1302,7 @@ public function parserThrowsExceptionWithCorrectLineNumberProvider()
13021302
),
13031303
array(
13041304
8,
1305-
<<<YAML
1305+
<<<'YAML'
13061306
foo:
13071307
-
13081308
# foobar
@@ -1315,7 +1315,7 @@ public function parserThrowsExceptionWithCorrectLineNumberProvider()
13151315
),
13161316
array(
13171317
10,
1318-
<<<YAML
1318+
<<<'YAML'
13191319
foo:
13201320
-
13211321
# foobar

0 commit comments

Comments
 (0)