Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DependencyInjection] Added support for variadics in named arguments#24937

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@PabloKowalczyk
Copy link
Contributor

@PabloKowalczykPabloKowalczyk commentedNov 12, 2017
edited
Loading

QA
Branch?4.1
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#24935
LicenseMIT

Koc and ro0NL reacted with thumbs up emoji
@linaori
Copy link
Contributor

As this is a new feature, it should target the master branch (which is 4.1). 3.4 is closed for new features and you're currently targeting 3.3, which will only receive bug fixes.

method_exists('ReflectionParameter','isVariadic')
) {
try {
$reflection =$this->getReflectionMethod($value,$method);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think a better implementation would hook into the existing foreach loop on line 56-57.
We just need aif (\PHP_VERSION_ID >= 50600 && $p->isVariadic() check inside the loop.
No need for enforcing this is the "last argument", PHP already did so.
And the key of the added params must be explicitly set ($resolvedArguments[$j++] instead of$resolvedArguments[], which can be wrong)

@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

should be removed

@chalasrchalasr added this to the4.1 milestoneNov 13, 2017
@PabloKowalczyk
Copy link
ContributorAuthor

@iltar should i open new PR?

@linaori
Copy link
Contributor

@PabloKowalczyk you'll have to change your branch to be based on the master, both locally and in in this PR, no need to create a new PR.

@PabloKowalczykPabloKowalczykforce-pushed thefeature/added-support-for-variadics-in-named-arguments branch from013f7fd to0219b3bCompareNovember 14, 2017 16:54
@PabloKowalczykPabloKowalczyk changed the base branch from3.3 tomasterNovember 14, 2017 16:55
foreach ($parametersas$j =>$p) {
if ($key ==='$'.$p->name) {
$resolvedArguments[$j] =$argument;
if (\PHP_VERSION_ID >=50600 &&$p->isVariadic() &&\is_array($argument)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Symfony 4.1 will require PHP 7. So this can be simplified.

}

/**
* @requires PHP 5.6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

not needed

Copy link
Contributor

@ro0NLro0NL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i think we should also test this inContainerBuilderTest andPhpDumperTest as well

@PabloKowalczyk
Copy link
ContributorAuthor

@ro0NL Could you give me more details, please? What methods should i test?


class NamedArgumentsVariadicsDummy
{
publicfunction__construct(...$variadics)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

for the tests, could you add another parameter before the variadic one so we show it works?

ro0NL reacted with thumbs up emoji
@sroze
Copy link
Contributor

@ro0NL what exactly are you willing to test? I'm not convinced yet of the value of more tests for these changes :)

@ro0NL
Copy link
Contributor

in general, you would test the usecase from a compiled/dumped container; asserting a real constructed service instead of a definition. But i agree the current test implies it should work 👍

@PabloKowalczykPabloKowalczykforce-pushed thefeature/added-support-for-variadics-in-named-arguments branch from9658d69 to27754efCompareNovember 19, 2017 11:57
@PabloKowalczykPabloKowalczykforce-pushed thefeature/added-support-for-variadics-in-named-arguments branch from27754ef toca5453eCompareNovember 20, 2017 19:59
@fabpot
Copy link
Member

Thank you@PabloKowalczyk.

@fabpotfabpot closed thisDec 1, 2017
fabpot added a commit that referenced this pull requestDec 1, 2017
…amed arguments (PabloKowalczyk)This PR was squashed before being merged into the 4.1-dev branch (closes#24937).Discussion----------[DependencyInjection] Added support for variadics in named arguments| Q             | A| ------------- | ---| Branch?       | 4.1| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#24935| License       | MITCommits-------b5c0e89 [DependencyInjection] Added support for variadics in named arguments
@PabloKowalczykPabloKowalczyk deleted the feature/added-support-for-variadics-in-named-arguments branchDecember 1, 2017 16:37
@fabpotfabpot mentioned this pull requestMay 7, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

@xabbuhxabbuhxabbuh left review comments

@fabpotfabpotfabpot approved these changes

@dunglasdunglasdunglas approved these changes

+2 more reviewers

@srozesrozesroze left review comments

@ro0NLro0NLro0NL left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

4.1

Development

Successfully merging this pull request may close these issues.

11 participants

@PabloKowalczyk@linaori@sroze@ro0NL@fabpot@dunglas@nicolas-grekas@stof@xabbuh@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp