-
Notifications
You must be signed in to change notification settings - Fork 59
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
Detect changes in ENUMs as BC breaks #768
Conversation
69e22a7
to
20779b5
Compare
If you approve the workflow I'll try to fix any issues it detects. I've run unit tests, psalm and phpcs on my local. It might be nice to have some end to end testing as well though. For this sort of project I wish git would work recursively, letting us have a git repo of a sample project inside this repo's test assets directory. |
@bdsl done |
I also noticed there seems to be quite a bit of code duplication in the existing code between the handling of Classes, Traits and Interface. I think there could be a nice way to remove that duplication, but I didn't want to get into restructuring the existing code on my first PR. E.g. the |
d195486
to
3d288ec
Compare
ah didn't realise you need to approve the workflow separately for every commit. I've turned on github actions in my fork so we can see the results there: https://github.com/bdsl/BackwardCompatibilityCheck/actions |
The Infection check is currently failing. But on my local using |
@Ocramius can you see where I'm going wrong with the mutation tests? On my laptop (php 8.3 with xdebug in WSL) I'm getting 0 returned from the infection command as shown below. I don't know if it could be because I'm running xdebug rather than phpdbg.
|
… in CompareClasses s
Afaik this product is a tool rather than a library, so I'm not sure if BC breaks on a function are really an issue, but the build is reporting an unexpected BC break here https://github.com/Roave/BackwardCompatibilityCheck/actions/runs/9148688556/job/25151720875
Infection detected that these were not needed
Perhaps it's using |
Yes possibly. I'll see if I can it working with phpdbg on my local. |
Trying to work out whether this is related to the infection check failure - I haven't been able to reproduce the way its failing on my local.
Perhaps the semantics are arguable, but I think it's safest to say making a case no longer internal is a BC break, as it means we no-longer gurantee to not return it and client code may need to check for it as part of an exhaustive match.
This is ready for re-review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final
to be added, plus some minor adjustments, then this can 🚢 :)
test/unit/DetectChanges/BCBreak/ClassBased/EnumCasesChangedTest.php
Outdated
Show resolved
Hide resolved
Co-authored-by: Marco Pivetta <ocramius@gmail.com>
All looking quite good! I'll do a local check of specific mutants before merging :-) |
Took me a bit (because I just switched my OS / main computer), but this is pristine when running with XDebug!
I will lower the MT requirements to get this merged, meanwhile :-) |
Note that MT MSI is 100% when running with XDebug, but 85.84% when running with `phpdbg`, which is no longer supported by PHPUnit. This will be fixed in a later iteration of the Laminas test container: laminas/laminas-ci-matrix-action#189
Yep, I ran infection on my local when I saw that it was failing on the build, so then killed all the mutants. There are some mutations I can imagine easily that are not tested, like deleting the untested "return trait" here or equivalently replacing the if condition with |
Meanwhile, 🚢 Thanks @bdsl! |
See #767
I went slightly further than discussed in the issue, reporting a BC break for cases removed, as well as for cases added. In both cases cases marked
@internal
do not trigger the BC break.I think there's more to do for a complete handling of enums, including detecting if an entire Enum is removed, or becomes a trait, class or interface. Actually I see the entire Enum removed is already handled by the catch of
IdentifierNotFound
BackwardCompatibilityCheck/src/CompareClasses.php
Line 76 in 4c05d1a
and I could easily extend this PR to handle became trait/interface/class by simply treating one of those as a thing that has no cases - so an enum becoming one of those is not an issue itself, its only an issue because it means cases go away. And an enum with no cases becoming a different sort of classlike is not a BC break. Let me know if you'd like me to do that.