Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0abe862

Browse files
committed
feature #21350 [Yaml] Remove internal arguments from the api (GuilhemN)
This PR was squashed before being merged into the 3.3-dev branch (closes #21350). Discussion ---------- [Yaml] Remove internal arguments from the api | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #21230 | License | MIT | Doc PR | Reopening of #21230 because of [@xabbuh's comment](#21194 (comment)). > This PR removes internal constructor arguments of the `Parser` class. > This should break nothing as they are only used to build errors message and are clearly meant for internal uses. > > This would allow to have a nicer api for #21194 (comment). Commits ------- ebae4ff [Yaml] Remove internal arguments from the api
2 parents 065ac8b + ebae4ff commit 0abe862

File tree

3 files changed

+27
-12
lines changed

3 files changed

+27
-12
lines changed

UPGRADE-3.3.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,10 @@ Workflow
6464

6565
* Deprecated class name support in `WorkflowRegistry::add()` as second parameter.
6666
Wrap the class name in an instance of ClassInstanceSupportStrategy instead.
67+
68+
Yaml
69+
----
70+
71+
* The constructor arguments `$offset`, `$totalNumberOfLines` and
72+
`$skippedLineNumbers` of the `Parser` class are deprecated and will be
73+
removed in 4.0

UPGRADE-4.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ Yaml
390390

391391
* Duplicate mapping keys lead to a `ParseException`.
392392

393+
* The constructor arguments `$offset`, `$totalNumberOfLines` and
394+
`$skippedLineNumbers` of the `Parser` class were removed.
395+
393396
Ldap
394397
----
395398

src/Symfony/Component/Yaml/Parser.php

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

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

4950
/**
@@ -384,7 +385,11 @@ private function parseBlock($offset, $yaml, $flags)
384385
$skippedLineNumbers[] = $lineNumber;
385386
}
386387

387-
$parser = new self($offset, $this->totalNumberOfLines, $skippedLineNumbers);
388+
$parser = new self();
389+
$parser->offset = $offset;
390+
$parser->totalNumberOfLines = $this->totalNumberOfLines;
391+
$parser->skippedLineNumbers = $skippedLineNumbers;
392+
388393
$parser->refs = &$this->refs;
389394

390395
return $parser->parse($yaml, $flags);

0 commit comments

Comments
 (0)