/** @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
{ $stamps =
[];
foreach ($encodedEnvelope['headers'
] as $name =>
$value) { if (!
str_starts_with($name, self::STAMP_HEADER_PREFIX
)) { continue;
}