Skip to content

Commit

Permalink
Apply php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLevti committed Nov 23, 2019
1 parent d11e644 commit 2d0951d
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 53 deletions.
8 changes: 1 addition & 7 deletions .php_cs.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'psr4' => true,
'binary_operator_spaces' => false,
'binary_operator_spaces' => true,
'array_syntax' => ['syntax' => 'short'],
'linebreak_after_opening_tag' => true,
'not_operator_with_successor_space' => true,
Expand Down Expand Up @@ -50,11 +50,5 @@ return PhpCsFixer\Config::create()
'compact_nullable_typehint' => true,
'ternary_operator_spaces' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => [
'default' => 'single_space',
'operators' => [
'|' => 'no_space',
]
]
])
->setFinder($finder);
4 changes: 2 additions & 2 deletions src/Spork/Batch/BatchJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function execute($callback = null)
*/
public function __invoke()
{
$forks = array();
$forks = [];
foreach ($this->strategy->createBatches($this->data) as $index => $batch) {
$forks[] = $this->manager
->fork($this->strategy->createRunner($batch, $this->callback))
Expand All @@ -91,7 +91,7 @@ public function __invoke()
// block until all forks have exited
$this->manager->wait();

$results = array();
$results = [];
foreach ($forks as $fork) {
$results = array_merge($results, $fork->getResult());
}
Expand Down
2 changes: 1 addition & 1 deletion src/Spork/Batch/BatchRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __invoke(SharedMemory $shm)
$this->batch = call_user_func($this->batch);
}

$results = array();
$results = [];
foreach ($this->batch as $index => $item) {
$results[$index] = call_user_func($this->callback, $item, $index, $this->batch, $shm);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Spork/Batch/Strategy/MongoStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public function createBatches($cursor)
throw new UnexpectedTypeException($cursor, $expected);
}

$skip = $this->skip;
$skip = $this->skip;
$limit = ceil(($cursor->count(true) - $skip) / $this->size);

$batches = array();
$batches = [];
for ($i = 0; $i < $this->size; $i++) {
$batches[] = function () use ($cursor, $skip, $i, $limit) {
return $cursor->skip($skip + $i * $limit)->limit($limit);
Expand Down
8 changes: 4 additions & 4 deletions src/Spork/Deferred/Deferred.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public function __construct()
{
$this->state = DeferredInterface::STATE_PENDING;

$this->progressCallbacks = array();
$this->alwaysCallbacks = array();
$this->doneCallbacks = array();
$this->failCallbacks = array();
$this->progressCallbacks = [];
$this->alwaysCallbacks = [];
$this->doneCallbacks = [];
$this->failCallbacks = [];
}

public function getState()
Expand Down
2 changes: 1 addition & 1 deletion src/Spork/Deferred/DeferredAggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(array $children)

// connect to each child
foreach ($this->children as $child) {
$child->always(array($this, 'tick'));
$child->always([$this, 'tick']);
}

// always tick once now
Expand Down
6 changes: 3 additions & 3 deletions src/Spork/Deferred/DeferredInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ interface DeferredInterface extends PromiseInterface
*
* @param mixed $args Any arguments will be passed along to the callbacks
*
* @return DeferredInterface The current promise
* @throws \LogicException If the promise is not pending
* @return DeferredInterface The current promise
*/
public function notify();

Expand All @@ -30,8 +30,8 @@ public function notify();
*
* @param mixed $args Any arguments will be passed along to the callbacks
*
* @return DeferredInterface The current promise
* @throws \LogicException If the promise was previously rejected
* @return DeferredInterface The current promise
*/
public function resolve();

Expand All @@ -42,8 +42,8 @@ public function resolve();
*
* @param mixed $args Any arguments will be passed along to the callbacks
*
* @return DeferredInterface The current promise
* @throws \LogicException If the promise was previously resolved
* @return DeferredInterface The current promise
*/
public function reject();
}
2 changes: 1 addition & 1 deletion src/Spork/Deferred/PromiseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

interface PromiseInterface
{
public const STATE_PENDING = 'pending';
public const STATE_PENDING = 'pending';
public const STATE_RESOLVED = 'resolved';
public const STATE_REJECTED = 'rejected';

Expand Down
2 changes: 1 addition & 1 deletion src/Spork/EventDispatcher/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function dispatchSignal($signal)
public function addSignalListener($signal, $callable, $priority = 0)
{
$this->addListener('spork.signal.' . $signal, $callable, $priority);
pcntl_signal($signal, array($this, 'dispatchSignal'));
pcntl_signal($signal, [$this, 'dispatchSignal']);
}

public function removeSignalListener($signal, $callable)
Expand Down
14 changes: 7 additions & 7 deletions src/Spork/Fork.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ class Fork implements DeferredInterface
public function __construct($pid, SharedMemory $shm, $debug = false)
{
$this->defer = new Deferred();
$this->pid = $pid;
$this->shm = $shm;
$this->pid = $pid;
$this->shm = $shm;
$this->debug = $debug;
$this->name = '<anonymous>';
$this->name = '<anonymous>';
}

/**
Expand Down Expand Up @@ -92,7 +92,7 @@ public function processWaitStatus($status)

public function receive()
{
$messages = array();
$messages = [];

foreach ($this->shm->receive() as $message) {
if ($message instanceof ExitMessage) {
Expand Down Expand Up @@ -221,7 +221,7 @@ public function notify()
$args = func_get_args();
array_unshift($args, $this);

call_user_func_array(array($this->defer, 'notify'), $args);
call_user_func_array([$this->defer, 'notify'], $args);

return $this;
}
Expand All @@ -231,7 +231,7 @@ public function resolve()
$args = func_get_args();
array_unshift($args, $this);

call_user_func_array(array($this->defer, 'resolve'), $args);
call_user_func_array([$this->defer, 'resolve'], $args);

return $this;
}
Expand All @@ -241,7 +241,7 @@ public function reject()
$args = func_get_args();
array_unshift($args, $this);

call_user_func_array(array($this->defer, 'reject'), $args);
call_user_func_array([$this->defer, 'reject'], $args);

return $this;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Spork/ProcessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(EventDispatcherInterface $dispatcher = null, Factory
$this->factory = $factory ?: new Factory();
$this->debug = $debug;
$this->zombieOkay = false;
$this->forks = array();
$this->forks = [];
}

public function __destruct()
Expand Down Expand Up @@ -100,7 +100,7 @@ public function fork($callable)

if (0 === $pid) {
// reset the list of child processes
$this->forks = array();
$this->forks = [];

// setup the shared memory
$shm = $this->factory->createSharedMemory(null, $this->signal);
Expand Down Expand Up @@ -156,7 +156,7 @@ public function fork($callable)
public function monitor($signal = SIGUSR1)
{
$this->signal = $signal;
$this->dispatcher->addSignalListener($signal, array($this, 'check'));
$this->dispatcher->addSignalListener($signal, [$this, 'check']);
}

public function check()
Expand Down
12 changes: 6 additions & 6 deletions src/Spork/SharedMemory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public function __construct($pid = null, $signal = null)
{
if (null === $pid) {
// child
$pid = posix_getpid();
$ppid = posix_getppid();
$pid = posix_getpid();
$ppid = posix_getppid();
} else {
// parent
$ppid = null;
$ppid = null;
}

$this->pid = $pid;
$this->pid = $pid;
$this->ppid = $ppid;
$this->signal = $signal;
}
Expand All @@ -59,7 +59,7 @@ public function receive()
return unserialize($serializedMessages);
}

return array();
return [];
}

/**
Expand All @@ -71,7 +71,7 @@ public function receive()
*/
public function send($message, $signal = null, $pause = 500)
{
$messageArray = array();
$messageArray = [];

if (($shmId = @shmop_open($this->pid, 'a', 0, 0)) > 0) {
// Read any existing messages in shared memory
Expand Down
4 changes: 2 additions & 2 deletions src/Spork/Util/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ public function setCode($code)

public function serialize()
{
return serialize(array(
return serialize([
$this->class,
$this->message,
$this->file,
$this->line,
$this->code,
));
]);
}

public function unserialize($str)
Expand Down
4 changes: 2 additions & 2 deletions src/Spork/Util/ExitMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ public function setError(Error $error)

public function serialize()
{
return serialize(array(
return serialize([
$this->result,
$this->output,
$this->error,
));
]);
}

public function unserialize($str)
Expand Down
1 change: 0 additions & 1 deletion tests/Spork/Batch/Strategy/ChunkStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Spork\Batch\Strategy;

use PHPUnit\Framework\TestCase;
use Spork\Batch\Strategy\ChunkStrategy;

class ChunkStrategyTest extends TestCase
{
Expand Down
1 change: 0 additions & 1 deletion tests/Spork/Batch/Strategy/MongoStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Spork\Batch\Strategy;

use PHPUnit\Framework\TestCase;
use Spork\Batch\Strategy\MongoStrategy;
use Spork\EventDispatcher\Events;
use Spork\ProcessManager;

Expand Down
2 changes: 0 additions & 2 deletions tests/Spork/Deferred/DeferredAggregateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
namespace Spork\Deferred;

use PHPUnit\Framework\TestCase;
use Spork\Deferred\Deferred;
use Spork\Deferred\DeferredAggregate;
use Spork\Exception\UnexpectedTypeException;

class DeferredAggregateTest extends TestCase
Expand Down
1 change: 0 additions & 1 deletion tests/Spork/Deferred/DeferredTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use LogicException;
use PHPUnit\Framework\TestCase;
use Spork\Deferred\Deferred;
use Spork\Exception\UnexpectedTypeException;

class DeferredTest extends TestCase
Expand Down
2 changes: 0 additions & 2 deletions tests/Spork/ProcessManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

use Exception;
use PHPUnit\Framework\TestCase;
use Spork\Fork;
use Spork\ProcessManager;

class ProcessManagerTest extends TestCase
{
Expand Down
2 changes: 0 additions & 2 deletions tests/Spork/SignalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
namespace Spork;

use PHPUnit\Framework\TestCase;
use Spork\ProcessManager;
use Spork\SharedMemory;

class SignalTest extends TestCase
{
Expand Down
2 changes: 0 additions & 2 deletions tests/Spork/Util/ThrottleIteratorStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Spork\Util;

use Spork\Util\ThrottleIterator;

class ThrottleIteratorStub extends ThrottleIterator
{
public $loads = [];
Expand Down

0 comments on commit 2d0951d

Please sign in to comment.