Skip to content

Commit

Permalink
Apply Rector changes (CI)
Browse files Browse the repository at this point in the history
  • Loading branch information
vjik authored and github-actions[bot] committed Nov 22, 2023
1 parent 8c061df commit e1b4bd6
Show file tree
Hide file tree
Showing 15 changed files with 8 additions and 33 deletions.
2 changes: 0 additions & 2 deletions src/Adapter/AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function status(string $id): JobStatus;

/**
* Pushing a message to the queue. Adapter sets message ID if available.
*
* @param MessageInterface $message
*/
public function push(MessageInterface $message): void;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ class ChannelIncorrectlyConfigured extends InvalidArgumentException implements F
/**
* ChannelIncorrectlyConfigured constructor.
*
* @param string $channel
* @param mixed|object $definition
* @param int $code
* @param Throwable|null $previous
*/
public function __construct(string $channel, $definition, int $code = 0, ?Throwable $previous = null)

Check warning on line 23 in src/Exception/AdapterConfiguration/ChannelIncorrectlyConfigured.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.0-ubuntu-latest

Escaped Mutant for Mutator "DecrementInteger": --- Original +++ New @@ @@ * @param mixed|object $definition * @param Throwable|null $previous */ - public function __construct(string $channel, $definition, int $code = 0, ?Throwable $previous = null) + public function __construct(string $channel, $definition, int $code = -1, ?Throwable $previous = null) { $adapterClass = AdapterInterface::class; $realType = get_debug_type($definition);

Check warning on line 23 in src/Exception/AdapterConfiguration/ChannelIncorrectlyConfigured.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.0-ubuntu-latest

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ * @param mixed|object $definition * @param Throwable|null $previous */ - public function __construct(string $channel, $definition, int $code = 0, ?Throwable $previous = null) + public function __construct(string $channel, $definition, int $code = 1, ?Throwable $previous = null) { $adapterClass = AdapterInterface::class; $realType = get_debug_type($definition);
Expand Down
1 change: 0 additions & 1 deletion src/Message/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
final class Message implements MessageInterface
{
/**
* @param string $handlerName
* @param mixed $data Message data, encodable by a queue adapter
* @param array $metadata Message metadata, encodable by a queue adapter
* @param string|null $id Message id
Expand Down
4 changes: 1 addition & 3 deletions src/Middleware/Consume/MiddlewareFactoryConsume.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ private function getFromContainer(string $middlewareDefinition): MiddlewareConsu
private function wrapCallable(callable $callback): MiddlewareConsumeInterface
{
return new class ($callback, $this->container) implements MiddlewareConsumeInterface {
private ContainerInterface $container;
private $callback;

public function __construct(callable $callback, ContainerInterface $container)
public function __construct(callable $callback, private ContainerInterface $container)
{
$this->callback = $callback;
$this->container = $container;
}

public function processConsume(ConsumeRequest $request, MessageHandlerConsumeInterface $handler): ConsumeRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ final class FailureMiddlewareDispatcher
private array $stack = [];

/**
* @param MiddlewareFactoryFailureInterface $middlewareFactory
* @param array[][]|callable[][]|MiddlewareFailureInterface[][]|string[][] $middlewareDefinitions
*/
public function __construct(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ final class ExponentialDelayMiddleware implements MiddlewareFailureInterface
* @param float $delayInitial The first delay period
* @param float $delayMaximum The maximum delay period
* @param float $exponent Message handling delay will be increased by this multiplication each time it fails
* @param DelayMiddlewareInterface $delayMiddleware
* @param QueueInterface|null $queue
*/
public function __construct(
Expand Down
4 changes: 1 addition & 3 deletions src/Middleware/FailureHandling/MiddlewareFactoryFailure.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,11 @@ private function getFromContainer(string $middlewareDefinition): MiddlewareFailu
private function wrapCallable(callable $callback): MiddlewareFailureInterface
{
return new class ($callback, $this->container) implements MiddlewareFailureInterface {
private ContainerInterface $container;
private $callback;

public function __construct(callable $callback, ContainerInterface $container)
public function __construct(callable $callback, private ContainerInterface $container)
{
$this->callback = $callback;
$this->container = $container;
}

public function processFailure(FailureHandlingRequest $request, MessageFailureHandlerInterface $handler): FailureHandlingRequest
Expand Down
4 changes: 1 addition & 3 deletions src/Middleware/InvalidMiddlewareDefinitionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ public function __construct($middlewareDefinition, int $code = 0, ?Throwable $pr
}

/**
* @param mixed $middlewareDefinition
*
* @return string|null
*/
private function convertDefinitionToString(mixed $middlewareDefinition): ?string
{
if (is_object($middlewareDefinition)) {
return 'an instance of "' . get_class($middlewareDefinition) . '"';
return 'an instance of "' . $middlewareDefinition::class . '"';
}

if (is_string($middlewareDefinition)) {
Expand Down
4 changes: 1 addition & 3 deletions src/Middleware/Push/MiddlewareFactoryPush.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ private function getFromContainer(string $middlewareDefinition): MiddlewarePushI
private function wrapCallable(callable $callback): MiddlewarePushInterface
{
return new class ($callback, $this->container) implements MiddlewarePushInterface {
private ContainerInterface $container;
private $callback;

public function __construct(callable $callback, ContainerInterface $container)
public function __construct(callable $callback, private ContainerInterface $container)
{
$this->callback = $callback;
$this->container = $container;
}

public function processPush(PushRequest $request, MessageHandlerPushInterface $handler): PushRequest
Expand Down
5 changes: 0 additions & 5 deletions src/QueueFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ final class QueueFactory implements QueueFactoryInterface
* "Definition" here is a {@see Factory} definition
* @param QueueInterface $queue A default queue implementation. `$queue->withAdapter()` will be returned
* with the `get` method
* @param ContainerInterface $container
* @param CallableFactory $callableFactory
* @param Injector $injector
* @param bool $enableRuntimeChannelDefinition A flag whether to enable a such behavior when there is no
* explicit channel adapter definition: `return $this->queue->withAdapter($this->adapter->withChannel($channel)`
* When this flag is set to false, only explicit definitions from the $definition parameter are used.
Expand Down Expand Up @@ -71,10 +68,8 @@ public function get(string $channel = self::DEFAULT_CHANNEL_NAME): QueueInterfac
}

/**
* @param string $channel
*
* @throws ChannelIncorrectlyConfigured
*
* @return QueueInterface
*/
private function create(string $channel): QueueInterface
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Middleware/Consume/MiddlewareDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function handleConsume(ConsumeRequest $request): ConsumeRequest
private function createDispatcher(
ContainerInterface $container = null,
): ConsumeMiddlewareDispatcher {
$container = $container ?? $this->createContainer([AdapterInterface::class => new FakeAdapter()]);
$container ??= $this->createContainer([AdapterInterface::class => new FakeAdapter()]);
$callableFactory = new CallableFactory($container);

return new ConsumeMiddlewareDispatcher(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ public function dataBase(): array

/**
* @dataProvider dataBase
*
* @param mixed $definition
* @param string $expected
*/
public function testBase(mixed $definition, string $expected): void
{
Expand All @@ -55,8 +52,6 @@ public function dataUnknownDefinition(): array

/**
* @dataProvider dataUnknownDefinition
*
* @param mixed $definition
*/
public function testUnknownDefinition(mixed $definition): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function handleFailure(FailureHandlingRequest $request): FailureHandlingR
private function createDispatcher(
ContainerInterface $container = null,
): FailureMiddlewareDispatcher {
$container = $container ?? $this->createContainer([AdapterInterface::class => new FakeAdapter()]);
$container ??= $this->createContainer([AdapterInterface::class => new FakeAdapter()]);
$callableFactory = new CallableFactory($container);

return new FailureMiddlewareDispatcher(new MiddlewareFactoryFailure($container, $callableFactory), []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function testInvalidMiddlewareWithWrongController(): void

private function getMiddlewareFactory(ContainerInterface $container = null): MiddlewareFactoryFailureInterface
{
$container = $container ?? $this->getContainer([AdapterInterface::class => new FakeAdapter()]);
$container ??= $this->getContainer([AdapterInterface::class => new FakeAdapter()]);

return new MiddlewareFactoryFailure($container, new CallableFactory($container));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Middleware/Push/MiddlewareFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function testInvalidMiddlewareWithWrongController(): void

private function getMiddlewareFactory(ContainerInterface $container = null): MiddlewareFactoryPushInterface
{
$container = $container ?? $this->getContainer([AdapterInterface::class => new FakeAdapter()]);
$container ??= $this->getContainer([AdapterInterface::class => new FakeAdapter()]);

return new MiddlewareFactoryPush($container, new CallableFactory($container));
}
Expand Down

0 comments on commit e1b4bd6

Please sign in to comment.