Skip to content
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
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
syntaxCheck="true"
verbose="true"
>
<testsuites>
Expand Down
2 changes: 1 addition & 1 deletion src/Busses/SynchronousCommandBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SynchronousCommandBus implements CommandBus
{
protected $resolver;

public function __construct(CommandHandlerResolver $resolver = null)
public function __construct(?CommandHandlerResolver $resolver = null)
{
$this->resolver = $resolver ?: new NativeCommandHandlerResolver;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Chief.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Chief implements CommandBus
* @param CommandBus $bus
* @param array $decorators Array of \Chief\Decorator objects
*/
public function __construct(CommandBus $bus = null, array $decorators = [])
public function __construct(?CommandBus $bus = null, array $decorators = [])
{
$this->bus = $bus ?: new SynchronousCommandBus;

Expand Down
2 changes: 1 addition & 1 deletion src/Decorators/CachingDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class CachingDecorator implements Decorator
* @param int $expiresAfter
* @param CommandBus $innerCommandBus
*/
public function __construct(CacheItemPoolInterface $cache, $expiresAfter = 3600, CommandBus $innerCommandBus = null)
public function __construct(CacheItemPoolInterface $cache, int $expiresAfter = 3600, ?CommandBus $innerCommandBus = null)
{
$this->cache = $cache;
$this->expiresAfter = $expiresAfter;
Expand Down
2 changes: 1 addition & 1 deletion src/Decorators/CommandQueueingDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CommandQueueingDecorator implements Decorator
* @param CommandQueuer $queuer
* @param CommandBus $innerCommandBus
*/
public function __construct(CommandQueuer $queuer, CommandBus $innerCommandBus = null)
public function __construct(CommandQueuer $queuer, ?CommandBus $innerCommandBus = null)
{
$this->queuer = $queuer;
$this->setInnerBus($innerCommandBus ?: new SynchronousCommandBus());
Expand Down
4 changes: 2 additions & 2 deletions src/Decorators/EventDispatchingDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class EventDispatchingDecorator implements Decorator

/**
* @param EventDispatcher $dispatcher
* @param CommandBus $innerCommandBus
* @param CommandBus|null $innerCommandBus
*/
public function __construct(EventDispatcher $dispatcher, CommandBus $innerCommandBus = null)
public function __construct(EventDispatcher $dispatcher, ?CommandBus $innerCommandBus = null)
{
$this->dispatcher = $dispatcher;
$this->setInnerBus($innerCommandBus ?: new SynchronousCommandBus());
Expand Down
2 changes: 1 addition & 1 deletion src/Decorators/LoggingDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class LoggingDecorator implements Decorator
* the command execution, such as the request/session information.
* @param CommandBus $innerCommandBus
*/
public function __construct(LoggerInterface $logger, $context = null, CommandBus $innerCommandBus = null)
public function __construct(LoggerInterface $logger, mixed $context = null, ?CommandBus $innerCommandBus = null)
{
$this->logger = $logger;
$this->context = $context;
Expand Down
2 changes: 1 addition & 1 deletion src/Decorators/TransactionalCommandLockingDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class TransactionalCommandLockingDecorator implements Decorator
*/
protected $queue = [];

public function __construct(CommandBus $innerCommandBus = null)
public function __construct(?CommandBus $innerCommandBus = null)
{
$this->setInnerBus($innerCommandBus ?: new SynchronousCommandBus());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resolvers/NativeCommandHandlerResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class NativeCommandHandlerResolver implements CommandHandlerResolver

protected $handlers = [];

public function __construct(Container $container = null)
public function __construct(?Container $container = null)
{
$this->container = $container ?: new NativeContainer;
}
Expand Down
14 changes: 12 additions & 2 deletions tests/Decorators/CachingDecoratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,22 @@ protected function getDecorator()

class FakeCachableCommand implements CacheableCommand
{
public $data;
private $data;

public function __construct($data)
{
$this->data = $data;
}

public function getData()
{
return $this->data;
}

public function setData($data)
{
$this->data = $data;
}
}

class FakeCachableCommandWithCacheOptions extends FakeCachableCommand implements HasCacheOptions
Expand All @@ -168,7 +178,7 @@ class FakeCachableCommandWithCacheOptions extends FakeCachableCommand implements

public function __construct($data, $expiry, $cacheKey)
{
$this->data = $data;
parent::__construct($data);
$this->expiry = $expiry;
$this->cacheKey = $cacheKey;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/Stubs/LogDecoratorCommandBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

class LogDecoratorCommandBus implements Decorator
{
public $logger;
public $commandBus;

public function __construct(LoggerInterface $logger, CommandBus $commandBus)
{
$this->logger = $logger;
Expand Down
4 changes: 3 additions & 1 deletion tests/Stubs/NonInterfaceImplementingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

use Chief\Command;

class NonInterfaceImplementingCommand implements Command {}
class NonInterfaceImplementingCommand implements Command {
public $handled = false;
}
2 changes: 2 additions & 0 deletions tests/Stubs/NonInterfaceImplementingCommandHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

class NonInterfaceImplementingCommandHandler
{
public $handled = false;

public function handle($command)
{
$command->handled = true;
Expand Down
2 changes: 2 additions & 0 deletions tests/Stubs/SelfHandlingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

class SelfHandlingCommand implements Command, CommandHandler
{
public $handled = false;

public function handle(Command $command)
{
$command->handled = true;
Expand Down
4 changes: 3 additions & 1 deletion tests/Stubs/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

use Chief\Command;

class TestCommand implements Command {}
class TestCommand implements Command {
public $handled = false;
}