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

Rename variadic parameter is not break BC #733

Open
vjik opened this issue Jan 24, 2023 · 3 comments
Open

Rename variadic parameter is not break BC #733

vjik opened this issue Jan 24, 2023 · 3 comments

Comments

@vjik
Copy link

vjik commented Jan 24, 2023

interface A {
    public function test(...$a): void;
}

change to

interface A {
    public function test(...$b): void;
}

This is not break BC.

All data pass to variadic parameter when named arguments used. For example: https://3v4l.org/stRQl

@Ocramius
Copy link
Member

Could we have that in a test case, perhaps? 🤔

@vjik
Copy link
Author

vjik commented Jan 25, 2023

Example of false-positive result: https://github.com/yiisoft/data/actions/runs/3999454619/jobs/6863373008

@Ocramius
Copy link
Member

I would need a patch touching these files:

public function __invoke(
ReflectionMethod|ReflectionFunction $fromFunction,
ReflectionMethod|ReflectionFunction $toFunction,
): Changes {
$fromHadNoNamedArgumentsAnnotation = $this->methodHasNoNamedArgumentsAnnotation($fromFunction);
$toHasNoNamedArgumentsAnnotation = $this->methodHasNoNamedArgumentsAnnotation($toFunction);
if ($fromHadNoNamedArgumentsAnnotation && ! $toHasNoNamedArgumentsAnnotation) {
return Changes::fromList(
Change::removed(
sprintf(
'The %s annotation was removed from %s',
self::NO_NAMED_ARGUMENTS_ANNOTATION,
$this->formatFunction->__invoke($fromFunction),
),
),
);
}
if (! $fromHadNoNamedArgumentsAnnotation && $toHasNoNamedArgumentsAnnotation) {
return Changes::fromList(
Change::added(
sprintf(
'The %s annotation was added from %s',
self::NO_NAMED_ARGUMENTS_ANNOTATION,
$this->formatFunction->__invoke($fromFunction),
),
),
);
}
if ($toHasNoNamedArgumentsAnnotation) {
return Changes::empty();
}
return Changes::fromIterator($this->checkSymbols(
$fromFunction->getParameters(),
$toFunction->getParameters(),
));
}

/** @covers \Roave\BackwardCompatibility\DetectChanges\BCBreak\FunctionBased\ParameterNameChanged */
final class ParameterNameChangedTest extends TestCase

@Ocramius Ocramius added this to the 8.3.0 milestone Jan 30, 2023
@Ocramius Ocramius removed this from the 8.3.0 milestone Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants