Skip to content
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

Named parameters are not available in any PHP 7 version #2

Closed
flowl opened this issue Jun 12, 2020 · 4 comments
Closed

Named parameters are not available in any PHP 7 version #2

flowl opened this issue Jun 12, 2020 · 4 comments

Comments

@flowl
Copy link

flowl commented Jun 12, 2020

Named parameters like in

$requestBuilder->setAccountDetails($receiverId = 'DE');

are not available in any PHP 7 version yet.

It is a feature planned for PHP 8 with people trying to backport it to PHP 7 but it has not yet been merged.

RFC: https://wiki.php.net/rfc/named_params
Merge request: php/php-src#5357
Version poc: https://3v4l.org/OoPIe

@moehrenzahn
Copy link

Hi flowl, thanks for your feedback!

This is not a named parameter, it is valid PHP syntax to illustrate what kind of value should be passed to the setAccountDetails method.

@flowl
Copy link
Author

flowl commented Jun 12, 2020

Just pointing out, it works because of the order beeing correct, not because of the named parameters.

While this works:

$requestBuilder->setShipperAddress(
    $name = 'Jane Doe',
    $countryCode = 'DE',
    $postalCode = '53113',
    $city = 'Bonn',
    $streetName = 'Sträßchensweg',
    $streetNumber = '2'
);

This doesn't:

$requestBuilder->setShipperAddress(
    $city = 'Bonn',
    $postalCode = '53113',
    $streetNumber = '2',
    $streetName = 'Sträßchensweg',
    $countryCode = 'DE',
    $name = 'Jane Doe',
);

@ngolatka
Copy link

@flowl Just a comment, but did you notice there is a trailing comma in your non-working example after "Jane Doe"?

@flowl
Copy link
Author

flowl commented Jun 15, 2020

@ngolatka no, but it doesn't work with removed comma either because named parameters are coming in PHP 8 if they don't merge it in PHP 7.5 or 7.4 latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants