Closed sbesselsen closed 5 years ago
@clue I think it makes sense to add a test. Not sure how we'd test this yet to be honest. But if @sbesselsen has an idea how to test this that would be great 👍
I'm also not sure how to test this. For me the patch is good as is. My only suggestion is to add a comment for the reasoning behind the is_object()
check.
Hi all, thanks for the feedback. I've added a comment as requested.
I've also thought about a good way to test it; the one thing I could think of was to create a test setup where we have a class with a method "then", and run resolve() with that class name. We would expect that promise to then resolve with the class name, whereas before we would get a PHP error "Call to a member function then() on string". Does that sound like a good test? I'm unsure because it would require us to define a class in the test script just for that purpose, which seems... strange?
When resolving a promise with a long string, the following may happen:
The method_exists() check only makes sense for objects, since further down the call
$promiseOrValue->then(...)
is made. Staticthen
methods aren't supported anyway.