Skip to content
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

Small fixes #76

Merged
merged 3 commits into from
Mar 21, 2024
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
5 changes: 1 addition & 4 deletions src/Bus/BusEnvelopeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@

final class BusEnvelopeCollection extends EnvelopeCollection
{
private TestBus $bus;

public function __construct(TestBus $bus, Envelope ...$envelope)
public function __construct(private TestBus $bus, Envelope ...$envelope)
{
$this->bus = $bus;
parent::__construct(...$envelope);
}

Expand Down
11 changes: 4 additions & 7 deletions src/EnvelopeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,7 @@ final public function assertNotContains(string $messageClass): static
return $this;
}

/**
* @param string|callable|null $filter
*/
final public function first($filter = null): TestEnvelope
final public function first(callable|string|null $filter = null): TestEnvelope
{
if (null === $filter) {
// just the first envelope
Expand Down Expand Up @@ -157,7 +154,7 @@ final public function count(): int

private static function normalizeFilter(callable $filter): callable
{
$function = new \ReflectionFunction(\Closure::fromCallable($filter));
$function = new \ReflectionFunction($filter(...));

if (!$parameter = $function->getParameters()[0] ?? null) {
return $filter;
Expand All @@ -172,8 +169,8 @@ private static function normalizeFilter(callable $filter): callable
}

// user used message class name as type-hint
return function(Envelope $envelope) use ($filter, $type) {
if ($type->getName() !== \get_class($envelope->getMessage())) {
return static function(Envelope $envelope) use ($filter, $type) {
if ($type->getName() !== $envelope->getMessage()::class) {
return false;
}

Expand Down
5 changes: 1 addition & 4 deletions src/TestEnvelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
*/
final class TestEnvelope
{
private Envelope $envelope;

public function __construct(Envelope $envelope)
public function __construct(private Envelope $envelope)
{
$this->envelope = $envelope;
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/Transport/TestTransportFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* @author Kevin Bond <kevinbond@gmail.com>
*
* @internal
*
* @implements TransportFactoryInterface<TestTransport>
*/
final class TestTransportFactory implements TransportFactoryInterface
{
Expand All @@ -36,7 +38,7 @@ public function createTransport(string $dsn, array $options, SerializerInterface

public function supports(string $dsn, array $options): bool // @phpstan-ignore-line
{
return 0 === \mb_strpos($dsn, 'test://');
return \str_starts_with($dsn, 'test://');
}

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Transport/TransportEnvelopeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@

final class TransportEnvelopeCollection extends EnvelopeCollection
{
private TestTransport $transport;

public function __construct(TestTransport $transport, Envelope ...$envelopes)
public function __construct(private TestTransport $transport, Envelope ...$envelopes)
{
$this->transport = $transport;
parent::__construct(...$envelopes);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/DelayStampTestTest.php → tests/DelayStampTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* @author Nicolas PHILIPPE <nikophil@gmail.com>
*/
final class DelayStampTestTest extends WebTestCase
final class DelayStampTest extends WebTestCase
{
use ClockSensitiveTrait;
use InteractsWithMessenger;
Expand Down
Loading