Skip to content

Removing method default parameter value should generate MAJOR level entry #83

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
ajant opened this issue Apr 27, 2016 · 6 comments
Closed

Comments

@ajant
Copy link

ajant commented Apr 27, 2016

Removing method default parameter value should generate MAJOR level entry. Because if you remove default value, you are changing the signature of the method, effectively breaking backwards compatibility. Before the change, you were able to call the method without providing said parameter and after the change, you have to provide it. Am I missing anything?

@tomzx
Copy link
Owner

tomzx commented Apr 28, 2016

If I'm not mistaken, this should be taken care by V002, V010 and V011.

As you've observed, the removal of a default parameter is similar to the addition of a new parameter to the function/method signature. I believe this case is already taken care of in https://github.com/tomzx/php-semver-checker/blob/master/src/PHPSemVerChecker/Comparator/Signature.php#L22:L27.

If that is not the case, could you please provide a test case where V002/V010/V011 is not triggered?

@ajant
Copy link
Author

ajant commented Apr 28, 2016

Then I'm definitely missing something. Admittedly I did use my project's composer.json & composer update to install the package into my project, against your recommendation, but I'm not sure that is the reason behind the problem:
"tomzx/php-semver-checker": "*"
I made no custom configurations. If I understood correctly V002, V010 and V011 should all cause MAJOR entry by default?
I also got same result after making custom configuration like this:
myconfig.json
{ "level": { "mapping": { "V002": "MAJOR", "V010": "MAJOR", "V011": "MAJOR" } } }

When I remove default params to try and trigger the V010 & V011, I only get V023, V024 & V060 triggered.

@tomzx
Copy link
Owner

tomzx commented Apr 28, 2016

You are correct, it appears there is a bug if the previous/after function are of the same length but their optional parameters have changed.

This however points out there's a couple of issues with the current verification rules, namely that we might have to create a set for the addition of new parameters with default or the conversion of a required parameter into an optional parameter (aka parameter with default value) (which is a minor change), the removal of a parameter's default value (which is a major change as you pointed out).

Supporting this change will be more involved than what I expected however, so I'll have to look into it a little more before anything can be fixed.

Thanks for reporting this issue.

@ajant
Copy link
Author

ajant commented May 4, 2016

No problem, glad I could help.

Do you have any timetable for this? I'm looking forward to using your library, as soon as the issue is fixed.

@tomzx
Copy link
Owner

tomzx commented May 5, 2016

Sadly, the whole function/method signature comparison needs a major overhaul.

As this project is not overly active, I cannot provide you with any timetable. However, I'll try to allocate myself some time to work on this issue this month. Hopefully it can be done within the month (with a bunch of new features/fixes).

tomzx added a commit that referenced this issue May 7, 2016
…ature:

- Parameter added/removed
- Parameter typing added/removed
- Parameter default added/removed
- Parameter default value changed
Major refactoring of the operations so that they only contain their code and reason, moving everything else to the *OperatorUnary/*OperatorDelta classes.
Major refactoring of the function analyzer and class method analyzer tests to test all visibilities and type (class/interface/trait).
[#83] Removing method default parameter value should generate MAJOR level entry
@tomzx
Copy link
Owner

tomzx commented May 7, 2016

I've been able to finish most of the bulk of the work (@c896df0b71b37d58891bddfb977a15e86fe1f392), however I believe there are still issues left (which will be discovered in time).

Note that rules V072, V094-V096, V078 and V112-V114 have been assigned to this.

Give it a try and let me know if you have any issues.

@tomzx tomzx closed this as completed May 7, 2016
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