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

False-positive result on add nullable type in final method of abstract class #313

Open
vjik opened this issue Jul 27, 2021 · 2 comments
Open

Comments

@vjik
Copy link

vjik commented Jul 27, 2021

Example:

abstract class X {
	final public function test(string $var): self
}

changed to:

abstract class X {
	final public function test(?string $var): self
}

result will be:

[BC] CHANGED: The parameter $var of X#test() changed from string to ?string

Real example: yiisoft/html#78

@Ocramius
Copy link
Member

So, if I understand correctly, if a method is final, then a contravariant type (expansion) is acceptable here.

The check should be this one:

final class ParameterTypeChanged implements FunctionBased

I think we need to restrict ParameterTypeChanged checks (see https://github.com/Roave/BackwardCompatibilityCheck/blob/7f185e3128276bbaa3d6c086ebee45e3ba02c374/bin/roave-backward-compatibility-check.php) to only non-contravariant, when the method is final.

@Ocramius Ocramius added this to the 5.1.0 milestone Jul 27, 2021
@Ocramius Ocramius modified the milestones: 5.1.0, 6.0.0 Nov 5, 2021
@Ocramius
Copy link
Member

Ocramius commented Nov 5, 2021

Not going to be able to drag this into 6.0 - removing milestone for now.

@Ocramius Ocramius removed this from the 6.0.0 milestone Nov 5, 2021
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