-
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! 🎄 |
Also include a demo of its usage.
In most classes, a stub that throws an exception is 'implemented'.
Part of #1440.