8000 [Messenger] Allow passing a string instead of an array in `TransportNamesStamp` by alexandre-daubois · Pull Request #49270 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Messenger] Allow passing a string instead of an array in TransportNamesStamp #49270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Messenger] Allow passing a string instead of an array in `TransportN…
…amesStamp`
  • Loading branch information
alexandre-daubois authored and nicolas-grekas committed Feb 10, 2023
commit ff86922a6d12decec3d220ab750f4ddb90cad1ad
1 change: 1 addition & 0 deletions src/Symfony/Component/Messenger/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ CHANGELOG
`Symfony\Component\Messenger\Transport\InMemoryTransportFactory` in favor of
`Symfony\Component\Messenger\Transport\InMemory\InMemoryTransport` and
`Symfony\Component\Messenger\Transport\InMemory\InMemoryTransportFactory`
* Allow passing a string instead of an array in `TransportNamesStamp`

6.2
---
Expand Down
7 changes: 5 additions & 2 deletions src/Symfony/Component/Messenger/Stamp/TransportNamesStamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
*/
final class TransportNamesStamp implements StampInterface
{
private array $transports;

/**
* @param string[] $transports Transport names to be used for the message
* @param string[]|string $transports Transport names to be used for the message
*/
public function __construct(private array $transports)
public function __construct(array|string $transports)
{
$this->transports = (array) $transports;
}

public function getTransportNames(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ public function testGetSenders()
$this->assertSame($sender, $stampSenders[$key]);
}
}

public function testGetIndividualSender()
{
$stamp = new TransportNamesStamp('first_transport');
$stampSenders = $stamp->getTransportNames();

$this->assertCount(1, $stampSenders);
$this->assertSame('first_transport', $stampSenders[0]);
}
}
0