-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
Matchers & Filters: use the right ReflectionProperty #35
Conversation
Hi, thank you for this very great analysis and PR! I would definitely prefer option 2 as well, but unfortunately we have to keep BC :( PHPUnit is using this library, so I definitely don't want to break BC if it can be avoided. It seems like option 1 is the only choice, do you have time to implement it? |
Well, considering that PHPUnit bounded the DeepCopy version I can PR a new CHANGELOG.md in the way PHPUnit does: http://keepachangelog.com/ You have to feel free to change API you if follow widespread rules and document it |
I don't want to have to maintain 2 versions of this library that has already a maintenance cost way to high compared to what it does. Releasing a new major version just for this small fix is not worth it IMO. A v2 would deserve some refactoring to simplify a lot the API. What we can do in the meantime is create a trait or base class that will add a helper to get the correct |
Independently from this PR, you should decide and declare what and how you intend to mantain. Beside that, I don't understand the statement "A v2 would deserve [...]", a version change is what you decide it has to be. What I suggest this project should do is:
Even with low resources and time available, changes shouldn't be feared because of others usages. What do you and other maintainers think? |
This packages already has a changelog and follows semver. My point is that for users, upgrading a major version takes time. Even if there are not many BC breaks. Creating multiple new major versions is not a good thing, what happens with Guzzle is a good example of that.
Keep in mind this is a small tool, not a framework. Users of this package don't look out for new features or versions, if they used the package it means it did the job for them. I don't think users would appreciate having to read changelogs and go over their old code just to be on a correctly maintained major version. It's much easier for them upgrading minors. So again, I am not against a new major version. But it has to be worth it. This PR can be solved easily without breaking BC, so it's not worth creating a new major version.
Yes, that's what I meant. I want v2 to be much simpler (big internal refactoring). I expect 80% of users not to be affected by this refactoring though (just like PHPUnit probably won't be). As it is now this packages has too many hacks and is too complex (internally and for users too). |
I observe and respect your point. Ping me again when you are ready for API changes, best regards. |
I'm sorry maybe I didn't express correctly what I was trying to say: I do think what you suggested as solution 1 is a good solution (coupled to a trait that would be an easy change I guess). And I do appreciate the time you are putting into this discussion. Are you opposed a solution that favors keeping BC? |
I am sorry if you intended my last comment as a rage quit, as it wasn't. The solution 1 would be really easy: just add a new method like But I do really believe that a simple and small project like this must/needs to act with a rigid policy of small deployments, even for API changes, to ease the workload of maintainers and the lightweight of the project itself. When I use a dependancy, I accept the fact that I will have to watch it: small complexity and small changes are easier to follow and will lead to less issues, even though they may seem a burden for the watching time cost. |
@mnapoli may you add this PR to 2.0 milestone so we have a reminder for the future please? Even if you are not going to tag a v2 (for now), better to have it hanging forever than hidden. |
Hello, i just stumbled into this issue as well with a class that extends a Doctrine ArrayCollection. Im not sure on what you agreed here, but I would welcome a soon BC keeping fix :) |
Hi @theofidry may I ask you why #88 was favored instead of this PR? With #88 you gather the property in DeepCopy, then pass the property name, and then re-gather the property again. |
@Slamdunk apologies this was not intended. Seems like it has been closed when switching the default branch |
When you are ready with the 2.0 branch, ping me and I'll rebase this PR |
Hi, may I ask why this PR was closed? |
Another switch of branch. I've deleted |
Sure: please reopen the PR and mark it as awaiting- author-updates, so I know the ball is up to me and I have to do something |
I cannot re-open the PR, the button is disabled: "The master branch has been deleted". (I would happily do so and re-target the branch otherwise) |
Currently DeepCopy does not allow to copy
private
properties on the parent class when Matchers and Filters are used, as I show in this new test: https://github.com/myclabs/DeepCopy/pull/35/files#diff-0fe594d8935dca0233edc25909b8267dR59This is because the
ReflectionHelper
gathers all the properties from parent classes but the Matchers and the Filters try to instantiate their ownReflectionProperty
, which raise anReflectionException
because private properties on parent class are not part of sub classes: https://3v4l.org/MuZPGThere are two solutions:
For this PR I chose the latter.
The current test on this subject, testPrivatePropertyOfParentObjectCopy, passes because no matchers and no filters are used.