-
-
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
Conversation
Can you rebase to get rid of the merge commit? |
06706f2
to
847fda8
Compare
Sure, sorry. |
FYI, I have updated the "Deprecations?" row of the PR description to match the actual changes. |
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 just left some minor comments about the wording of the deprecation message. Otherwise, the changes look good to me.
$this->totalNumberOfLines = $totalNumberOfLines; | ||
$this->skippedLineNumbers = $skippedLineNumbers; | ||
if (func_num_args() > 0) { | ||
@trigger_error(sprintf('Constructor arguments $offset, $totalNumberOfLines, $skippedLineNumbers of %s are deprecated and will be removed in 4.0', self::class), E_USER_DEPRECATED); |
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.
The constructor arguments [...]
Yaml | ||
---- | ||
|
||
* Constructor arguments `$offset`, `$totalNumberOfLines` and |
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.
The constructor arguments [...]
---- | ||
|
||
* Constructor arguments `$offset`, `$totalNumberOfLines` and | ||
`$skippedLineNumbers` of `Parser` are deprecated and will be |
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.
[...] of the Parser
class [...]
@@ -391,6 +391,9 @@ Yaml | |||
|
|||
* Duplicate mapping keys lead to a `ParseException`. | |||
|
|||
* Constructor arguments `$offset`, `$totalNumberOfLines` and |
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 would make the she changes as in the other upgrade file here too.
👍 after the changes proposed by @xabbuh |
$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 comment
The reason will be displayed to describe this comment to others. Learn more.
instead of having to do a if func > 0
, if func_args > 1
, ..., you can leave the optionnal parameters in the constructor (just undocument those) and just check if func_num_args > 0
to trigger the deprecation :
<?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 comment
The 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.
847fda8
to
e176c09
Compare
@xabbuh I fixed your comments. |
* @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()) |
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.
Thank you @GuilhemN. |
Reopening of #21230 because of @xabbuh's comment.