Closed
Description
Description
Why does symfony/messenger/Envelope.php (https://github.com/symfony/messenger/blob/master/Envelope.php) support only complex types (classes)? Look at 34 line there is get_class method which makes impossible to use primitive types (like string or boolean).
It's a problem because symfony doesn't support any other header data (it parses only X-Message-Envelope-Items header). How do I share header information between a few microservices?
Example
If we really want to support only EnvelopeItemInterface items, it's still easy to implement primitives.
There is example:
public function __construct($message, array $items = array())
{
$this->message = $message;
foreach ($items as $item) {
if (!is_object($item)) {
switch (detect_type($item)) {
case TYPE_BOOLEAN:
$item = new EnvelopeItemBoolean($item);
break;
case TYPE_STRING:
$item = new EnvelopeItemString($item);
break;
// ..array, int, null
}
}
$this->items[\get_class($item)] = $item;
}
}