8000 [Yaml] Remove internal arguments from the api by GuilhemN · Pull Request #21350 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove constructor arguments
  • Loading branch information
GuilhemN authored Jan 21, 2017
commit 1a4626dc5467aab0f0a3c3f186483b2ef7788b73
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Parser
private $skippedLineNumbers = array();
private $locallySkippedLineNumbers = array();

public function __construct($offset = 0, $totalNumberOfLines = null, array $skippedLineNumbers = array())
public function __construct()
{
if (func_num_args() > 0) {
Copy link
Contributor
@Taluu Taluu Jan 20, 2017

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)

Copy link
Contributor Author

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.

@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);
Expand Down
0