-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Labels
BugDXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)SerializerStatus: Needs Review
Description
Symfony version(s) affected
5.0-7.1
Description
The normalize()
method in the Symfony\Component\Serializer\Normalizer\NormalizerInterface
interface has the first argument named object
, yet in the class implementing this interface, Symfony\Component\Serializer\Serializer
, the first argument is called data
. This discrepancy prevents the use of a named argument.
Fatal error: Uncaught Error: Unknown named parameter $object
How to reproduce
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class DummyService {
public function __construct(private readonly NormalizerInterface $normalizer) {}
public summy($object): array
{
return $this->normalizer->normalize(
object: $value,
context: [
'some' => 'context'
],
);
}
}
Possible Solution
Rename first argument of Symfony\Component\Serializer\Serializer::normalize()
class as described in interface
Additional Context
Perhaps it's unlikely that anyone will use the named argument as the first parameter, but it does seem like an inconsistency in implementation, I suppose. Thanks.
Metadata
Metadata
Assignees
Labels
BugDXDX = Developer eXperience (anything that improves the experience of using Symfony)DX = Developer eXperience (anything that improves the experience of using Symfony)SerializerStatus: Needs Review