Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
### Added

- d806fe4: Added phpstan to travis for static code analysis.

### Changed

- #1: PHP 7.2 min requirement and updated library to support it.
- #4: Added DBAL usage documentation and updated existing examples.
- 2d0951d: Applied PSR12 and additional rules to library.

### Removed

- #1: Removed support for PHP <7.2.
- d806fe4: Removed deprecated mongo db support.

### Fixed

- d806fe4: Fixed static code analysis issues.
  • Loading branch information
TheLevti committed Dec 8, 2019
2 parents 5d575ca + 19b5f8e commit 1f5ed45
Show file tree
Hide file tree
Showing 20 changed files with 67 additions and 196 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
/.gitignore export-ignore
/.travis.yml export-ignore
/php_cs.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.php_cs
/.phpunit.result.cache
/composer.lock
/phpstan.neon
/phpunit.xml
/vendor
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cache:
php:
- 7.2
- 7.3
- 7.4
- nightly

matrix:
Expand All @@ -20,5 +21,6 @@ install:
- composer install --no-progress --no-scripts --no-suggest --no-interaction

script:
- vendor/bin/phpunit --coverage-text
- vendor/bin/phpcs --standard=PSR12 src/ tests/
- vendor/bin/phpstan analyse --no-progress --no-ansi --no-interaction
- vendor/bin/phpunit --no-interaction --colors=never
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.0] - 2019-11-29

### Added

- d806fe4: Added phpstan to travis for static code analysis.

### Changed

- #1: PHP 7.2 min requirement and updated library to support it.
Expand All @@ -17,7 +21,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

- #1: Removed support for PHP <7.2
- #1: Removed support for PHP <7.2.
- d806fe4: Removed deprecated mongo db support.

### Fixed

- d806fe4: Fixed static code analysis issues.

## [0.3.0] - 2015-05-18

Expand All @@ -29,4 +38,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added serializable objects for exit and error messages.

[Unreleased]: https://github.com/TheLevti/spork/compare/0.3.0...HEAD
[1.0.0]: https://github.com/TheLevti/spork/releases/1.0.0
[0.3.0]: https://github.com/TheLevti/spork/releases/0.3.0
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"ext-posix": "*",
"ext-shmop": "*",
"friendsofphp/php-cs-fixer": "^2.16",
"phpstan/phpstan": "^0.11.19",
"phpunit/phpunit": "^8.4",
"squizlabs/php_codesniffer": "^3.5"
},
Expand All @@ -68,6 +69,7 @@
"/.gitignore",
"/.travis.yml",
"/php_cs.dist",
"/phpstan.neon.dist",
"/phpunit.xml.dist",
"/tests"
]
Expand Down
6 changes: 6 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
level: max
paths:
- src
- tests
inferPrivatePropertyTypeFromConstructor: true
2 changes: 1 addition & 1 deletion src/Spork/Batch/Strategy/ChunkStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function createBatches($data)
$data = iterator_to_array($data);
}

$size = ceil(count($data) / $this->forks);
$size = (int)ceil(count($data) / $this->forks);

return array_chunk($data, $size, $this->preserveKeys);
}
Expand Down
17 changes: 0 additions & 17 deletions src/Spork/Batch/Strategy/DoctrineMongoStrategy.php

This file was deleted.

63 changes: 0 additions & 63 deletions src/Spork/Batch/Strategy/MongoStrategy.php

This file was deleted.

5 changes: 5 additions & 0 deletions src/Spork/Deferred/Deferred.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@

class Deferred implements DeferredInterface
{
/** @var string $state */
private $state;
/** @var array $progressCallbacks */
private $progressCallbacks;
/** @var array $alwaysCallbacks */
private $alwaysCallbacks;
/** @var array $doneCallbacks */
private $doneCallbacks;
/** @var array $failCallbacks */
private $failCallbacks;
private $callbackArgs;

Expand Down
15 changes: 6 additions & 9 deletions src/Spork/Deferred/DeferredInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
interface DeferredInterface extends PromiseInterface
{
/**
* Notifies the promise of progress.
*
* @param mixed $args Any arguments will be passed along to the callbacks
* Notifies the promise of progress. Any arguments will be passed along to
* the callbacks.
*
* @throws \LogicException If the promise is not pending
* @return DeferredInterface The current promise
Expand All @@ -26,9 +25,8 @@ public function notify();
/**
* Marks the current promise as successful.
*
* Calls "always" callbacks first, followed by "done" callbacks.
*
* @param mixed $args Any arguments will be passed along to the callbacks
* Calls "always" callbacks first, followed by "done" callbacks. Any
* arguments will be passed along to the callbacks
*
* @throws \LogicException If the promise was previously rejected
* @return DeferredInterface The current promise
Expand All @@ -38,9 +36,8 @@ public function resolve();
/**
* Marks the current promise as failed.
*
* Calls "always" callbacks first, followed by "fail" callbacks.
*
* @param mixed $args Any arguments will be passed along to the callbacks
* Calls "always" callbacks first, followed by "fail" callbacks. Any
* arguments will be passed along to the callbacks.
*
* @throws \LogicException If the promise was previously resolved
* @return DeferredInterface The current promise
Expand Down
2 changes: 1 addition & 1 deletion src/Spork/Deferred/PromiseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function done($done);
*
* The callback will be called immediately if the promise state is rejected.
*
* @param callable $done The callback
* @param callable $fail The callback
*
* @return PromiseInterface The current promise
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Spork/EventDispatcher/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Spork\EventDispatcher;

use Symfony\Component\EventDispatcher\EventDispatcher as BaseEventDispatcher;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Adds support for listening to signals.
Expand All @@ -22,7 +23,7 @@ class EventDispatcher extends BaseEventDispatcher implements EventDispatcherInte
{
public function dispatchSignal($signal)
{
$this->dispatch('spork.signal.' . $signal);
$this->dispatch(new Event(), 'spork.signal.' . $signal);
}

public function addSignalListener($signal, $callable, $priority = 0)
Expand Down
12 changes: 6 additions & 6 deletions src/Spork/EventDispatcher/WrappedEventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@

namespace Spork\EventDispatcher;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface as BaseEventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface as BaseInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\EventDispatcher\Event;

class WrappedEventDispatcher implements EventDispatcherInterface
{
private $delegate;

public function __construct(BaseEventDispatcherInterface $delegate)
public function __construct(BaseInterface $delegate)
{
$this->delegate = $delegate;
}

public function dispatchSignal($signal)
{
$this->delegate->dispatch('spork.signal.' . $signal);
$this->dispatch(new Event(), 'spork.signal.' . $signal);
}

public function addSignalListener($signal, $callable, $priority = 0)
Expand All @@ -42,9 +42,9 @@ public function removeSignalListener($signal, $callable)
$this->delegate->removeListener('spork.signal.' . $signal, $callable);
}

public function dispatch($eventName, Event $event = null)
public function dispatch($event, string $eventName = null)
{
return $this->delegate->dispatch($eventName, $event);
return call_user_func([$this->delegate, 'dispatch'], ...func_get_args());
}

public function addListener($eventName, $listener, $priority = 0)
Expand Down
6 changes: 3 additions & 3 deletions src/Spork/Fork.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function notify()
$args = func_get_args();
array_unshift($args, $this);

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

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

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

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

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

return $this;
}
Expand Down
6 changes: 4 additions & 2 deletions src/Spork/ProcessManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
use Spork\Exception\UnexpectedTypeException;
use Spork\Util\Error;
use Spork\Util\ExitMessage;
use Symfony\Contracts\EventDispatcher\Event;

class ProcessManager
{
private $dispatcher;
private $factory;
private $debug;
/** @var bool $zombieOkay */
private $zombieOkay;
private $signal;

Expand Down Expand Up @@ -92,7 +94,7 @@ public function fork($callable)
}

// allow the system to cleanup before forking
$this->dispatcher->dispatch(Events::PRE_FORK);
call_user_func([$this->dispatcher, 'dispatch'], new Event(), Events::PRE_FORK);

if (-1 === $pid = pcntl_fork()) {
throw new ProcessControlException('Unable to fork a new process');
Expand Down Expand Up @@ -124,7 +126,7 @@ public function fork($callable)
});

// dispatch an event so the system knows it's in a new process
$this->dispatcher->dispatch(Events::POST_FORK);
call_user_func([$this->dispatcher, 'dispatch'], new Event(), Events::POST_FORK);

if (!$this->debug) {
ob_start();
Expand Down
Loading

0 comments on commit 1f5ed45

Please sign in to comment.