Description
The addition/removal of the final keyword on existing class and class/trait methods is currently not considered as having a semantic versioning impact.
I suggest adding the following rules in order to cover this new requirement.
Visibility (public, protected, private) applies to classes/trait methods.
Classes
At the class level
Code | Level | Rule |
---|---|---|
VXXX | MAJOR | Added |
VXXX | MINOR | Removed |
Classes with final keyword on the class
The case is for a class that already has the final modifier applied to it, but where we're adding/removing methods.
Code | Level | Rule |
---|---|---|
---- | ----- | - Added |
VXXX | PATCH | -- Public |
VXXX | PATCH | -- Protected |
VXXX | PATCH | -- Private |
---- | ----- | - Removed |
VXXX | PATCH | -- Public |
VXXX | PATCH | -- Protected |
VXXX | PATCH | -- Private |
Classes without final keyword on the class but with final keyword on the methods
The case is for a class that does not have the final modifier applied to it and where we're adding/removing methods with the final keyword.
Code | Level | Rule |
---|---|---|
---- | ----- | - Added |
VXXX | MAJOR | -- Public |
VXXX | MAJOR | -- Protected |
VXXX | MAJOR | -- Private |
---- | ----- | - Removed |
VXXX | MAJOR | -- Public |
VXXX | MAJOR | -- Protected |
VXXX | MAJOR | -- Private |
Adding the final keyword to a private method will prevent class that inherit from this class from having a method with the same name.
Traits
The case is for a trait but where we're adding/removing methods with the final keyword.
Code | Level | Rule |
---|---|---|
---- | ----- | - Added |
VXXX | MAJOR | -- Public |
VXXX | MAJOR | -- Protected |
VXXX | PATCH | -- Private |
---- | ----- | - Removed |
VXXX | MINOR | -- Public |
VXXX | MINOR | -- Protected |
VXXX | PATCH | -- Private |
The rule levels are up for discussion.
This creates 18 new rules.
This brings an interesting question if we relate this issue with #49, which is, can we consider the addition/removal of class and class/trait methods with the final modifier as a two step process (adding/removing the class/trait/method + adding/removing the final modifier). I'll have to do an analysis of the two to see if they are the same in the end or if they need to be handled separately.