8000 Fix comments · symfony/symfony@67c4ee3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 67c4ee3

Browse files
committed
Fix comments
1 parent 851f7e2 commit 67c4ee3

File tree

5 files changed

+31
-36
lines changed

5 files changed

+31
-36
lines changed

UPGRADE-3.3.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,3 @@ TwigBridge
5959

6060
* The `TwigRendererEngine::setEnvironment()` method has been deprecated and will be removed
6161
in 4.0. Pass the Twig Environment as second argument of the constructor instead.
62-
63-
Yaml
64-
----
65-
66-
* Constructor arguments `$offset`, `$totalNumberOfLines` and
67-
`$skippedLineNumbers` of `Parser` are deprecated and will be
68-
removed in 4.0

UPGRADE-4.0.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ Serializer
216216
* The ability to pass a Doctrine `Cache` instance to the `ClassMetadataFactory`
217217
class has been removed. You should use the `CacheClassMetadataFactory` class
218218
instead.
219-
219+
220220
* Not defining the 6th argument `$format = null` of the
221221
`AbstractNormalizer::instantiateObject()` method when overriding it is not
222222
supported anymore.
@@ -294,7 +294,7 @@ Validator
294294
// ...
295295
}
296296
```
297-
297+
298298
* The default value of the strict option of the `Choice` Constraint has been
299299
changed to `true` as of 4.0. If you need the previous behaviour ensure to
300300
set the option to `false`.
@@ -390,6 +390,3 @@ Yaml
390390
the `!php/object` tag.
391391

392392
* Duplicate mapping keys lead to a `ParseException`.
393-
394-
* Constructor arguments `$offset`, `$totalNumberOfLines` and
395-
`$skippedLineNumbers` of `Parser` were removed.

src/Symfony/Component/Yaml/Inline.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static function parse($value, $flags = 0, $references = array())
106106
++$i;
107107
break;
108108
default:
109-
$result = self::parseScalar($value, $flags, null, $i, true, $references);
109+
$result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
110110
}
111111

112112
if (null !== $tag) {
@@ -413,7 +413,7 @@ private static function parseSequence($sequence, $flags, &$i = 0, $references =
413413
break;
414414
default:
415415
$isQuoted = in_array($sequence[$i], array('"', "'"));
416-
$value = self::parseScalar($sequence, $flags, array(',', ']'), $i, true, $references);
416+
$value = self::parseScalar($sequence, $flags, array(',', ']'), $i, null === $tag, $references);
417417

418418
// the value can be an array if a reference has been resolved to an array var
419419
if (is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
@@ -492,6 +492,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
492492
continue;
493493
}
494494

495+
$tag = self::parseTag($mapping, $i, $flags);
495496
$duplicate = false;
496497
switch ($mapping[$i]) {
497498
case '[':
@@ -517,7 +518,7 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
517518
}
518519
break;
519520
default:
520-
$value = self::parseScalar($mapping, $flags, array(',', '}'), $i, true, $references);
521+
$value = self::parseScalar($mapping, $flags, array(',', '}'), $i, null === $tag, $references);
521522
// Spec: Keys MUST be unique; first one wins.
522523
// Parser cannot abort this mapping earlier, since lines
523524
// are processed sequentially.
@@ -529,7 +530,11 @@ private static function parseMapping($mapping, $flags, &$i = 0, $references = ar
529530
}
530531

531532
if (!$duplicate) {
532-
$output[$key] = $value;
533+
if (null !== $tag) {
534+
$output[$key] = new TaggedValue($value, $tag);
535+
} else {
536+
$output[$key] = $value;
537+
}
533538
}
534539
++$i;
535540

@@ -633,7 +638,7 @@ private static function evaluateScalar($scalar, $flags, $references = array())
633638
@trigger_error(sprintf('Using the unquoted scalar value "%s" is deprecated since version 3.3 and will be considered as a tagged value in 4.0. You must quote it.', $scalar), E_USER_DEPRECATED);
634639
}
635640

636-
// Optimise for returning strings.
641+
// Optimize for returning strings.
637642
case $scalar[0] === '+' || $scalar[0] === '-' || $scalar[0] === '.' || is_numeric($scalar[0]):
638643
switch (true) {
639644
case preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar):
@@ -687,10 +692,11 @@ private static function evaluateScalar($scalar, $flags, $references = array())
687692
/**
688693
* @param string $value
689694
* @param int &$i
695+
* @param int $flags
690696
*
691-
* @return null|array|string
697+
* @return null|string
692698
*/
693-
private static function parseTag($value, &$i = 0, $flags)
699+
private static function parseTag($value, &$i, $flags)
694700
{
695701
if ('!' !== $value[$i]) {
696702
return;
@@ -703,12 +709,12 @@ private static function parseTag($value, &$i = 0, $flags)
703709
$nextOffset += strspn($value, ' ', $nextOffset);
704710

705711
// Is followed by a scalar
706-
if (!isset($value[$nextOffset]) || !in_array($value[$nextOffset], array('[', '{'))) {
712+
if (!isset($value[$nextOffset]) || !in_array($value[$nextOffset], array('[', '{'), true)) {
707713
// Manage scalars in {@link self::evaluateScalar()}
708714
return;
709715
}
710716

711-
if ($flags & Yaml::PARSE_CUSTOM_TAGS) {
717+
if (Yaml::PARSE_CUSTOM_TAGS & $flags) {
712718
$i = $nextOffset;
713719

714720
return $tag;

src/Symfony/Component/Yaml/Parser.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,18 @@ class Parser
3333
private $skippedLineNumbers = array();
3434
private $locallySkippedLineNumbers = array();
3535

36-
public function __construct()
36+
/**
37+
* Constructor.
38+
*
39+
* @param int $offset The offset of YAML document (used for line numbers in error messages)
40+
* @param int|null $totalNumberOfLines The overall number of lines being parsed
41+
* @param int[] $skippedLineNumbers Number of comment lines that have been skipped by the parser
42+
*/
43+
public function __construct($offset = 0, $totalNumberOfLines = null, array $skippedLineNumbers = array())
3744
{
38-
if (func_num_args() > 0) {
39-
@trigger_error(sprintf('Constructor arguments $offset, $totalNumberOfLines, $skippedLineNumbers of %s are deprecated and will be removed in 4.0', self::class), E_USER_DEPRECATED);
40-
41-
$this->offset = func_get_arg(0);
42-
if (func_num_args() > 1) {
43-
$this->totalNumberOfLines = func_get_arg(1);
44-
}
45-
if (func_num_args() > 2) {
46-
$this->skippedLineNumbers = func_get_arg(2);
47-
}
48-
}
45+
$this->offset = $offset;
46+
$this->totalNumberOfLines = $totalNumberOfLines;
47+
$this->skippedLineNumbers = $skippedLineNumbers;
4948
}
5049

5150
/**
@@ -981,7 +980,7 @@ private function getLineTag($value, $flags, $nextLineCheck = true)
981980
return;
982981
}
983982

984-
if ($flags & Yaml::PARSE_CUSTOM_TAGS) {
983+
if (Yaml::PARSE_CUSTOM_TAGS & $flags) {
985984
return substr($matches['tag'], 1);
986985
}
987986

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,10 +1527,10 @@ public function taggedValuesProvider()
15271527
YAML
15281528
),
15291529
'inline' => array(
1530-
array(new TaggedValue(array('foo', 'bar'), 'foo'), new TaggedValue(array('foo' => 'bar', 'quz' => 'one'), '!quz')),
1530+
array(new TaggedValue(array('foo', 'bar'), 'foo'), new TaggedValue(array('foo' => 'bar', 'quz' => new TaggedValue(array('one' => 'bar'), 'bar')), '!quz')),
15311531
<<<YAML
15321532
- !foo [foo, bar]
1533-
- !!quz {foo: bar, quz: one}
1533+
- !!quz {foo: bar, quz: !bar {one: bar}}
15341534
YAML
15351535
),
15361536
);

0 commit comments

Comments
 (0)
0