-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Yaml] Remove internal arguments from the api #21350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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()) | ||
{ | ||
$this->offset = $offset; | ||
$this->totalNumberOfLines = $totalNumberOfLines; | ||
$this->skippedLineNumbers = $skippedLineNumbers; | ||
if (func_num_args() > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of having to do a <?php
$f = function ($a = null, $b = null, array $c = array())
{
var_dump(func_num_args());
if (func_num_args() > 0) {
trigger();
}
// ...
}
$f(); // output 0, no deprecation
$f(1); // output 1, deprecation
// and so on It's cleaner IMO (and less conditionnals too) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But then they'll be automatically inserted by IDEs. Imo it is better to remove them to ensure people won't use deprecated arguments and only know it by executing the code. |
||
@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 @@ private function parseBlock($offset, $yaml, $flags) | |
$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); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use
func_get_arg()
, we should remove the arguments here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍, i forgot to revert it.