Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 591f1f4

Browse files
[Messenger] Allow passing a string instead of an array in TransportNamesStamp
1 parent 3e79a27 commit 591f1f4

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/Symfony/Component/Messenger/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CHANGELOG
99
`Symfony\Component\Messenger\Transport\InMemoryTransportFactory` in favor of
1010
`Symfony\Component\Messenger\Transport\InMemory\InMemoryTransport` and
1111
`Symfony\Component\Messenger\Transport\InMemory\InMemoryTransportFactory`
12+
* Allow passing a string instead of an array in `TransportNamesStamp`
1213

1314
6.2
1415
---

src/Symfony/Component/Messenger/Stamp/TransportNamesStamp.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616
*/
1717
final class TransportNamesStamp implements StampInterface
1818
{
19+
private array $transportNames;
20+
1921
/**
20-
* @param string[] $transports Transport names to be used for the message
22+
* @param string[]|string $transports Transport names to be used for the message
2123
*/
22-
public function __construct(private array $transports)
24+
public function __construct(array|string $transports)
2325
{
26+
$this->transportNames = (array) $transports;
2427
}
2528

2629
public function getTransportNames(): array
2730
{
28-
return $this->transports;
31+
return $this->transportNames;
2932
}
3033
}

src/Symfony/Component/Messenger/Tests/Stamp/TransportNamesStampTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,13 @@ public function testGetSenders()
2727
$this->assertSame($sender, $stampSenders[$key]);
2828
}
2929
}
30+
31+
public function testGetIndividualSender()
32+
{
33+
$stamp = new TransportNamesStamp('first_transport');
34+
$stampSenders = $stamp->getTransportNames();
35+
36+
$this->assertCount(1, $stampSenders);
37+
$this->assertSame('first_transport', $stampSenders[0]);
38+
}
3039
}

0 commit comments

Comments
 (0)