Skip to content

Commit

Permalink
Use empty array instead of null as default
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Aug 10, 2015
1 parent a7ce4c4 commit ef31ba2
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions src/Loop/AbstractLoop.php
Expand Up @@ -261,7 +261,7 @@ public function stop()
/**
* {@inheritdoc}
*/
public function queue(callable $callback, array $args = null)
public function queue(callable $callback, array $args = [])
{
$this->callableQueue->insert($callback, $args);
}
Expand Down Expand Up @@ -293,15 +293,15 @@ public function await($resource, callable $callback)
/**
* {@inheritdoc}
*/
public function timer($interval, $periodic, callable $callback, array $args = null)
public function timer($interval, $periodic, callable $callback, array $args = [])
{
return $this->timerManager->create($interval, $periodic, $callback, $args);
}

/**
* {@inheritdoc}
*/
public function immediate(callable $callback, array $args = null)
public function immediate(callable $callback, array $args = [])
{
return $this->immediateManager->create($callback, $args);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Loop/Events/EventFactory.php
Expand Up @@ -35,15 +35,15 @@ public function timer(
$interval,
$periodic,
callable $callback,
array $args = null
array $args = []
) {
return new Timer($manager, $interval, $periodic, $callback, $args);
}

/**
* {@inheritdoc}
*/
public function immediate(ImmediateManagerInterface $manager, callable $callback, array $args = null)
public function immediate(ImmediateManagerInterface $manager, callable $callback, array $args = [])
{
return new Immediate($manager, $callback, $args);
}
Expand Down
8 changes: 4 additions & 4 deletions src/Loop/Events/EventFactoryInterface.php
Expand Up @@ -30,7 +30,7 @@ public function socket(SocketManagerInterface $manager, $resource, callable $cal
* @param int|float $interval Timer interval.
* @param bool $periodic Set to true to repeat the timer every interval seconds, false for a one-time timer.
* @param callable $callback Callback function invoked after the interval elapses.
* @param mixed[]|null $args Arguments to pass to the callback function.
* @param mixed[] $args Arguments to pass to the callback function.
*
* @return \Icicle\Loop\Events\TimerInterface
*/
Expand All @@ -39,17 +39,17 @@ public function timer(
$interval,
$periodic,
callable $callback,
array $args = null
array $args = []
);

/**
* @param \Icicle\Loop\Manager\ImmediateManagerInterface $manager
* @param callable $callback Callback function to be invoked.
* @param mixed[]|null $args Arguments to pass to the callback function.
* @param mixed[] $args Arguments to pass to the callback function.
*
* @return \Icicle\Loop\Events\ImmediateInterface
*/
public function immediate(ImmediateManagerInterface $manager, callable $callback, array $args = null);
public function immediate(ImmediateManagerInterface $manager, callable $callback, array $args = []);

/**
* @param \Icicle\Loop\Manager\SignalManagerInterface $manager
Expand Down
4 changes: 2 additions & 2 deletions src/Loop/Events/Immediate.php
Expand Up @@ -31,9 +31,9 @@ class Immediate implements ImmediateInterface
/**
* @param \Icicle\Loop\Manager\ImmediateManagerInterface $manager
* @param callable $callback Function called when the interval expires.
* @param array $args Optional array of arguments to pass the callback function.
* @param mixed[] $args Optional array of arguments to pass the callback function.
*/
public function __construct(ImmediateManagerInterface $manager, callable $callback, array $args = null)
public function __construct(ImmediateManagerInterface $manager, callable $callback, array $args = [])
{
$this->manager = $manager;
$this->callback = $callback;
Expand Down
4 changes: 2 additions & 2 deletions src/Loop/Events/Timer.php
Expand Up @@ -51,14 +51,14 @@ class Timer implements TimerInterface
* @param int|float $interval Number of seconds until the callback function is called.
* @param bool $periodic True to repeat the timer, false to only run it once.
* @param callable $callback Function called when the interval expires.
* @param mixed[]|null $args Optional array of arguments to pass the callback function.
* @param mixed[] $args Optional array of arguments to pass the callback function.
*/
public function __construct(
TimerManagerInterface $manager,
$interval,
$periodic,
callable $callback,
array $args = null
array $args = []
) {
$this->manager = $manager;
$this->interval = (float) $interval;
Expand Down
12 changes: 6 additions & 6 deletions src/Loop/LoopInterface.php
Expand Up @@ -80,9 +80,9 @@ public function maxQueueDepth($depth);
* Callbacks are called in the order queued.
*
* @param callable<(mixed ...$args): void> $callback
* @param mixed[]|null $args Array of arguments to be passed to the callback function.
* @param mixed[] $args Array of arguments to be passed to the callback function.
*/
public function queue(callable $callback, array $args = null);
public function queue(callable $callback, array $args = []);

/**
* Creates an event object that can be used to listen for available data on the stream socket.
Expand Down Expand Up @@ -114,21 +114,21 @@ public function await($resource, callable $callback);
* @param int|float $interval
* @param bool $periodic
* @param callable<(mixed ...$args): void> $callback
* @param mixed[]|null $args
* @param mixed[] $args
*
* @return \Icicle\Loop\Events\TimerInterface
*/
public function timer($interval, $periodic, callable $callback, array $args = null);
public function timer($interval, $periodic, callable $callback, array $args = []);

/**
* Creates an immediate object connected to the loop.
*
* @param callable<(mixed ...$args): void> $callback
* @param mixed[]|null $args
* @param mixed[] $args
*
* @return \Icicle\Loop\Events\ImmediateInterface
*/
public function immediate(callable $callback, array $args = null);
public function immediate(callable $callback, array $args = []);

/**
* @param int $signo
Expand Down
2 changes: 1 addition & 1 deletion src/Loop/Manager/AbstractSignalManager.php
Expand Up @@ -48,7 +48,7 @@ public function __construct(LoopInterface $loop, EventFactoryInterface $factory)
/**
* {@inheritdoc}
*/
public function create($signo, callable $callback, array $args = null)
public function create($signo, callable $callback, array $args = [])
{
if (!isset($this->signals[$signo])) {
throw new InvalidSignalError(sprintf('Invalid signal number: %d.', $signo));
Expand Down
2 changes: 1 addition & 1 deletion src/Loop/Manager/Event/TimerManager.php
Expand Up @@ -89,7 +89,7 @@ public function isEmpty()
/**
* {@inheritdoc}
*/
public function create($interval, $periodic, callable $callback, array $args = null)
public function create($interval, $periodic, callable $callback, array $args = [])
{
$timer = $this->factory->timer($this, $interval, $periodic, $callback, $args);

Expand Down
2 changes: 1 addition & 1 deletion src/Loop/Manager/ImmediateManager.php
Expand Up @@ -50,7 +50,7 @@ public function __construct(LoopInterface $loop, EventFactoryInterface $factory)
/**
* {@inheritdoc}
*/
public function create(callable $callback, array $args = null)
public function create(callable $callback, array $args = [])
{
$immediate = $this->factory->immediate($this, $callback, $args);

Expand Down
2 changes: 1 addition & 1 deletion src/Loop/Manager/ImmediateManagerInterface.php
Expand Up @@ -21,7 +21,7 @@ interface ImmediateManagerInterface
*
* @return \Icicle\Loop\Events\ImmediateInterface
*/
public function create(callable $callback, array $args = null);
public function create(callable $callback, array $args = []);

/**
* Puts the immediate in the loop again for execution.
Expand Down
2 changes: 1 addition & 1 deletion src/Loop/Manager/Libevent/TimerManager.php
Expand Up @@ -94,7 +94,7 @@ public function isEmpty()
/**
* {@inheritdoc}
*/
public function create($interval, $periodic, callable $callback, array $args = null)
public function create($interval, $periodic, callable $callback, array $args = [])
{
$timer = $this->factory->timer($this, $interval, $periodic, $callback, $args);

Expand Down
2 changes: 1 addition & 1 deletion src/Loop/Manager/Select/TimerManager.php
Expand Up @@ -54,7 +54,7 @@ public function __construct(SelectLoop $loop, EventFactoryInterface $factory)
/**
* {@inheritdoc}
*/
public function create($interval, $periodic, callable $callback, array $args = null)
public function create($interval, $periodic, callable $callback, array $args = [])
{
$timer = $this->factory->timer($this, $interval, $periodic, $callback, $args);

Expand Down
2 changes: 1 addition & 1 deletion src/Loop/Manager/SignalManagerInterface.php
Expand Up @@ -22,7 +22,7 @@ interface SignalManagerInterface
*
* @return \Icicle\Loop\Events\SignalInterface
*/
public function create($signo, callable $callback, array $args = null);
public function create($signo, callable $callback, array $args = []);

/**
* Enables listening for the signal.
Expand Down
2 changes: 1 addition & 1 deletion src/Loop/Manager/TimerManagerInterface.php
Expand Up @@ -23,7 +23,7 @@ interface TimerManagerInterface
*
* @return \Icicle\Loop\Events\TimerInterface
*/
public function create($interval, $periodic, callable $callback, array $args = null);
public function create($interval, $periodic, callable $callback, array $args = []);

/**
* Starts the given timer if it is not already pending.
Expand Down
4 changes: 2 additions & 2 deletions src/Loop/Structures/CallableQueue.php
Expand Up @@ -37,9 +37,9 @@ public function __construct($depth = 0)

/**
* @param callable $callback
* @param mixed[]|null $args
* @param mixed[] $args
*/
public function insert(callable $callback, array $args = null)
public function insert(callable $callback, array $args = [])
{
$this->queue[] = [$callback, $args];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Loop/Events/ImmediateTest.php
Expand Up @@ -22,7 +22,7 @@ public function setUp()
$this->manager = $this->getMock(ImmediateManagerInterface::class);
}

public function createImmediate(callable $callback, array $args = null)
public function createImmediate(callable $callback, array $args = [])
{
return new Immediate($this->manager, $callback, $args);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Loop/Events/TimerTest.php
Expand Up @@ -24,7 +24,7 @@ public function setUp()
$this->manager = $this->getMock(TimerManagerInterface::class);
}

public function createTimer($interval, $periodic, callable $callback, array $args = null)
public function createTimer($interval, $periodic, callable $callback, array $args = [])
{
return new Timer($this->manager, $interval, $periodic, $callback, $args);
}
Expand Down

0 comments on commit ef31ba2

Please sign in to comment.