-
Notifications
You must be signed in to change notification settings - Fork 149
[TASK] Add getArrayRepresentation method for testing
#1441
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
base: main
Are you sure you want to change the base?
Conversation
Also include a demo of its usage. In most classes, a stub that throws an exception is 'implemented'. Part of #1440.
|
Notes:
|
|
I like this a lot! A few thoughts:
WDYT? |
|
And maybe we can add a corresponding PHPStan custom type to the interface. |
Agree. I only included it as a proof-of-concept to see how it would work in practice.
If I understand correctly, you're suggesting that each class implementing
I think I disagree here :) Many of the abstract classes contain some properties which should be put in the returned array. It should be the responsibility of those classes to do that for their own properties - not have every 'leaf' class repeating the same job. I concur that this means that when the method is implemented in a 'leaf' class, it will mean that it also implemented (possibly incompletely) for all of its cousins. I think this is workable - the demo shows that it is.
I also thought of adding a trait for that (but didn't go that far). I'd prefer that to writing the class name as a literal, which seems a bit clunky. Some day we may rename some of the classes; having a string literal to update would be an extra change that may be missed.
I'm not seeing how this would help. It seems to be about defining an array type with specific keys. We will have different keys depending on the class of object being represented. Neither does it offer a solution to the recursive type problem. Look forward to your further thoughts, and 🎄🦌☃️🌟🍷 ... have a good Christmas :) |
Yes, exactly. :-) As for the naming, maybe we can use |
Okay, I can live with having the method in abstract classes as well. :-) Merry Christmas to you, too! 🎄 |
oliverklee
left a comment
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.
As this is the POC (as I understand it), should I create the non-POC version from it, or are you planning to do that?
|
You're welcome to. I'm away for a couple more days without access to GitHub (can't sign in from phone due to 2FA so hope this message gets through).
|
Am back now. I think we've agreed the way forward. One of us should create the next PR for actual merging, whether based on this or a fresh one. But we should avoid duplication of effort... ;) |
I'm currently still focusing on my end-of year "thinking about my life" ritual and won't work on this until including January 1st. If you want to work on this during this time, please go ahead. (I'll be able to do the reviews, though.) |
Also include a demo of its usage.
In most classes, a stub that throws an exception is 'implemented'.
Part of #1440.