$context =
$this->context;
/** @var SerializerStamp|null $serializerStamp */
if ($serializerStamp =
$envelope->
last(SerializerStamp::
class)) { $context =
$serializerStamp->
getContext() +
$context;
} /** @var SerializedMessageStamp|null $serializedMessageStamp */
$serializedMessageStamp =
$envelope->
last(SerializedMessageStamp::
class);
$envelope =
$envelope->
withoutStampsOfType(NonSendableStampInterface::
class);
$headers =
['type' =>
$envelope->
getMessage()::
class] +
$this->
encodeStamps($envelope) +
$this->
getContentTypeHeader();
return [ 'body' =>
$serializedMessageStamp ?
$serializedMessageStamp->
getSerializedMessage() :
$this->serializer->
serialize($envelope->
getMessage(),
$this->format,
$context),
'headers' =>
$headers,
];
} private function decodeStamps(array
$encodedEnvelope): array
{