-
Notifications
You must be signed in to change notification settings - Fork 147
[TASK] Use getArrayRepresentation() in ValueTest
#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
Conversation
|
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.) |
I do most of that throughout the year whilst trying to get back to sleep in the middle of the night :/
I've set the ball rolling with #1447. Will keep this PR open for visibility, even though it may never itself be merged. |
5b4cc3e to
5ca221a
Compare
7d1f175 to
31b2828
Compare
getArrayRepresentation method for testinggetArrayRepresentation() in ValueTest
|
This now just includes using |
| ], | ||
| ], | ||
| 'separator' => ',', | ||
| 'name' => 'max', |
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.
Using assertSame() means the array keys must be in matching order, though it seems slightly illogical for name to be last.
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.
Maybe we can use assertEqualsCanonicalizing instead so we can have the array elements in a more readable order in the test.
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.
Ah, I take taht back. We'd want something like assertSameCanonicalizing (as we want to do a strict comparison), which does not exist.
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.
Ah, I take taht back. We'd want something like
assertSameCanonicalizing(as we want to do a strict comparison), which does not exist.
That would be nice to have. Also, assertEqualsCanonicalizing sorts the array by value, whereas we want it sorted by key to be canonical. I've thought of a way to get CSSFunction to return the array in a more logical order without significant overhead or duplication, which I'll submit as a separate PR if it works...
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.
That said, this particular test is somewhat convoluted. Other simpler tests may not need to worry about the order of the array keys.
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.
I've thought of a way to get
CSSFunctionto return the array in a more logical order without significant overhead or duplication, which I'll submit as a separate PR if it works...
|
I've marked the sniffer job as required. So we need to rebase to run all now-required jobs. |
... in `parsesArithmeticInFunctions()` test. Follows on from #1440.
31b2828 to
3947ca3
Compare
Done. |
... in
parsesArithmeticInFunctions()test.Follows on from #1440.