diff --git a/UPGRADE-3.3.md b/UPGRADE-3.3.md index aa1fe3a686..afd31e75ec 100644 --- a/UPGRADE-3.3.md +++ b/UPGRADE-3.3.md @@ -64,3 +64,10 @@ Workflow * Deprecated class name support in `WorkflowRegistry::add()` as second parameter. Wrap the class name in an instance of ClassInstanceSupportStrategy instead. + +Yaml +---- + + * The constructor arguments `$offset`, `$totalNumberOfLines` and + `$skippedLineNumbers` of the `Parser` class are deprecated and will be + removed in 4.0 diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 2a051a8c72..d88fc607d7 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -390,6 +390,9 @@ Yaml * Duplicate mapping keys lead to a `ParseException`. + * The constructor arguments `$offset`, `$totalNumberOfLines` and + `$skippedLineNumbers` of the `Parser` class were removed. + Ldap ---- diff --git a/src/Symfony/Component/Yaml/Parser.php b/src/Symfony/Component/Yaml/Parser.php index 14147a6aee..45359bac24 100644 --- a/src/Symfony/Component/Yaml/Parser.php +++ b/src/Symfony/Component/Yaml/Parser.php @@ -32,18 +32,19 @@ class Parser private $skippedLineNumbers = array(); private $locallySkippedLineNumbers = array(); - /** - * Constructor. - * - * @param int $offset The offset of YAML document (used for line numbers in error messages) - * @param int|null $totalNumberOfLines The overall number of lines being parsed - * @param int[] $skippedLineNumbers Number of comment lines that have been skipped by the parser - */ - public function __construct($offset = 0, $totalNumberOfLines = null, array $skippedLineNumbers = array()) + public function __construct() { - $this->offset = $offset; - $this->totalNumberOfLines = $totalNumberOfLines; - $this->skippedLineNumbers = $skippedLineNumbers; + if (func_num_args() > 0) { + @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); + + $this->offset = func_get_arg(0); + if (func_num_args() > 1) { + $this->totalNumberOfLines = func_get_arg(1); + } + if (func_num_args() > 2) { + $this->skippedLineNumbers = func_get_arg(2); + } + } } /** @@ -384,7 +385,11 @@ class Parser $skippedLineNumbers[] = $lineNumber; } - $parser = new self($offset, $this->totalNumberOfLines, $skippedLineNumbers); + $parser = new self(); + $parser->offset = $offset; + $parser->totalNumberOfLines = $this->totalNumberOfLines; + $parser->skippedLineNumbers = $skippedLineNumbers; + $parser->refs = &$this->refs; return $parser->parse($yaml, $flags);