Closed titoko closed 2 years ago
Hello! Thanks for the contribution! Would it be possible to add some test cases for it, please? Just to make sure that it works for older & new versions.
Best, Marcin.
Well, don't know if the test is really relevant but at least it should avoid regression :) . Tell me if it's enough for you
I think it would be better to check if it is callable - to make sure that it is not dependent on function name :) What do you think about something like:
public function testSerializeFormInterface()
{
$registry = new HandlerRegistry([]);
$registry->registerSubscribingHandler($this->handler);
$callback = $registry->getHandler(GraphNavigatorInterface::DIRECTION_SERIALIZATION, FormInterface::class, 'json');
$serialised = $callback($this->visitor, $this->createForm(), []);
// ...assert result? :)
}
It looks like it fails with similar result:
Error: Call to undefined method JMS\Serializer\Handler\FormErrorHandler::serializeFormInterfaceTojson()
Since Symfony 6.1 FormErrorIterator property $form is typehint to FormInterface since https://github.com/symfony/symfony/commit/85065e4f76eb0e75163277498bbc4fadb3ae49f8 .
This PR https://github.com/schmittjoh/serializer/pull/1362 add the possibility to serialize Interface but lead to the following error
call_user_func_array(): Argument #1 ($callback) must be a valid callback, class JMS\Serializer\Handler\FormErrorHandler does not have a method "serializeFormInterfaceTojson"
( see also https://github.com/FriendsOfSymfony/FOSRestBundle/pull/2371 )Adding the method option fix this issue