Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Oct 1, 2019
1 parent b686805 commit d810e4b
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 108 deletions.
24 changes: 17 additions & 7 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
# language: php

build:
dependencies:
before:
- 'composer self-update'
- 'composer update --prefer-stable --prefer-source --no-interaction --no-progress --no-suggest'
cache:
directories:
- vendor/
nodes:
analysis:
project_setup:
override: true
tests:
override: [php-scrutinizer-run]

filter:
paths: [src/*]
excluded_paths: [tests/*, vendor/*]

before_commands:
- 'composer self-update'
- 'composer update --prefer-stable --prefer-source --no-interaction --no-scripts --no-progress --no-suggest'

coding_style:
php:
upper_lower_casing:
Expand All @@ -17,8 +28,8 @@ coding_style:
true_false_null: lower
spaces:
around_operators:
concatenation: true
negation: false
concatenation: true
negation: false
other:
after_type_cast: true

Expand All @@ -34,7 +45,6 @@ tools:
enabled: true
config:
ruleset: 'unusedcode,naming,design,controversial,codesize'

php_cpd: true
php_loc: true
php_pdepend: true
Expand Down
20 changes: 11 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ env:
- COMPOSER_FLAGS="--prefer-stable --prefer-dist"

php:
- 7.2
- 7.3
- 7.4snapshot
- nightly

matrix:
Expand All @@ -22,25 +24,25 @@ matrix:
- php: 7.1
env:
- COMPOSER_FLAGS="--prefer-lowest --prefer-stable --prefer-dist"
- php: 7.2
- php: 7.1
env:
- TEST_VERSION=true
- COMPOSER_FLAGS="--prefer-stable --prefer-dist"
allow_failures:
- php: nightly

before_install:
- if [[ -z $TEST_VERSION && -f "/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini" ]]; then phpenv config-rm xdebug.ini; fi
- composer global require hirak/prestissimo
- composer self-update --stable --no-progress
- if [[ -z $TEST_VERSION && -f "/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini" ]]; then phpenv config-rm xdebug.ini; fi
- composer global require hirak/prestissimo
- composer self-update --stable --no-progress

install:
- travis_retry composer update $COMPOSER_FLAGS --no-interaction --no-scripts --no-progress
- if [[ $TEST_VERSION ]]; then travis_retry composer require php-coveralls/php-coveralls $COMPOSER_FLAGS --no-interaction --no-scripts --no-progress ; fi
- travis_retry composer update $COMPOSER_FLAGS --no-interaction --no-progress
- if [[ $TEST_VERSION ]]; then travis_retry composer require php-coveralls/php-coveralls $COMPOSER_FLAGS --no-interaction --no-scripts --no-progress ; fi

script:
- if [[ $TEST_VERSION ]]; then composer qa && composer report-phpunit-clover ; fi
- if [[ -z $TEST_VERSION ]]; then composer test-phpunit ; fi
- if [[ $TEST_VERSION ]]; then composer qa && composer report-phpunit-clover ; fi
- if [[ -z $TEST_VERSION ]]; then composer test-phpunit ; fi

after_script:
- if [[ $TEST_VERSION ]]; then travis_retry php vendor/bin/php-coveralls --verbose ; fi
- if [[ $TEST_VERSION ]]; then travis_retry php vendor/bin/php-coveralls --verbose ; fi
19 changes: 10 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,24 @@
"prefer-stable": true,
"require": {
"php": "^7.1",
"phpgears/event": "~0.1",
"symfony/event-dispatcher": "^4.1"
"phpgears/event": "~0.2",
"symfony/event-dispatcher": "^4.3"
},
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.1",
"friendsofphp/php-cs-fixer": "^2.0",
"infection/infection": "^0.9",
"phpmd/phpmd": "^2.0",
"phpstan/phpstan": "^0.11",
"phpstan/phpstan-deprecation-rules": "^0.11",
"phpstan/phpstan-strict-rules": "^0.11",
"phpunit/phpunit": "^6.0|^7.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "~0.11.12",
"phpstan/phpstan-deprecation-rules": "~0.11.2",
"phpstan/phpstan-strict-rules": "~0.11.1",
"phpunit/phpunit": "^7.0|^8.0",
"povils/phpmnd": "^2.0",
"roave/security-advisories": "dev-master",
"sebastian/phpcpd": "^3.0|^4.0",
"squizlabs/php_codesniffer": "^2.0",
"thecodingmachine/phpstan-strict-rules": "^0.11"
"sebastian/phpcpd": "^4.0",
"squizlabs/php_codesniffer": "^3.0",
"thecodingmachine/phpstan-strict-rules": "~0.11.2"
},
"suggest": {
},
Expand Down
5 changes: 0 additions & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon

parameters:
level: max
paths:
Expand Down
23 changes: 15 additions & 8 deletions src/ContainerAwareDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

use Gears\Event\EventHandler;
use Psr\Container\ContainerInterface;
use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyEventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent;

class ContainerAwareDispatcher extends SymfonyEventDispatcher implements EventDispatcher
{
Expand All @@ -34,6 +34,8 @@ class ContainerAwareDispatcher extends SymfonyEventDispatcher implements EventDi
*/
public function __construct(ContainerInterface $container, array $listenersMap = [])
{
parent::__construct();

$this->container = $container;

foreach ($listenersMap as $eventName => $listeners) {
Expand Down Expand Up @@ -89,25 +91,30 @@ public function addListener($eventName, $listener, $priority = 0): void
}

/**
* {@inheritdoc}
* Dispatches an event to all registered listeners.
*
* @param mixed $eventEnvelope
*
* @return SymfonyEvent
*/
public function dispatch($eventName, SymfonyEvent $event = null): SymfonyEvent
public function dispatch($eventEnvelope): SymfonyEvent
{
if ($event === null) {
if ($eventEnvelope === null) {
throw new \InvalidArgumentException('Dispatched event cannot be empty');
}

if (!$event instanceof EventEnvelope) {
if (!$eventEnvelope instanceof EventEnvelope) {
throw new \InvalidArgumentException(\sprintf(
'Dispatched event must implement %s, %s given',
EventEnvelope::class,
\get_class($event)
\get_class($eventEnvelope)
));
}

$this->dispatchEvent($this->getListeners($eventName), $event);
$eventName = \get_class($eventEnvelope->getWrappedEvent());
$this->dispatchEvent($this->getListeners($eventName), $eventEnvelope);

return $event;
return $eventEnvelope;
}

/**
Expand Down
23 changes: 15 additions & 8 deletions src/Dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
namespace Gears\Event\Symfony\Dispatcher;

use Gears\Event\EventHandler;
use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyEventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent;

class Dispatcher extends SymfonyEventDispatcher implements EventDispatcher
{
Expand All @@ -27,6 +27,8 @@ class Dispatcher extends SymfonyEventDispatcher implements EventDispatcher
*/
public function __construct(array $listenersMap = [])
{
parent::__construct();

foreach ($listenersMap as $eventName => $listeners) {
if (!\is_array($listeners)) {
$listeners = [$listeners];
Expand Down Expand Up @@ -79,25 +81,30 @@ public function addListener($eventName, $listener, $priority = 0): void
}

/**
* {@inheritdoc}
* Dispatches an event to all registered listeners.
*
* @param mixed $eventEnvelope
*
* @return SymfonyEvent
*/
public function dispatch($eventName, SymfonyEvent $event = null): SymfonyEvent
public function dispatch($eventEnvelope): SymfonyEvent
{
if ($event === null) {
if ($eventEnvelope === null) {
throw new \InvalidArgumentException('Dispatched event cannot be empty');
}

if (!$event instanceof EventEnvelope) {
if (!$eventEnvelope instanceof EventEnvelope) {
throw new \InvalidArgumentException(\sprintf(
'Dispatched event must implement %s, %s given',
EventEnvelope::class,
\get_class($event)
\get_class($eventEnvelope)
));
}

$this->dispatchEvent($this->getListeners($eventName), $event);
$eventName = \get_class($eventEnvelope->getWrappedEvent());
$this->dispatchEvent($this->getListeners($eventName), $eventEnvelope);

return $event;
return $eventEnvelope;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/EventBus.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ final class EventBus implements EventBusInterface
/**
* Wrapped event dispatcher.
*
* @var ContainerAwareDispatcher
* @var EventDispatcher
*/
private $wrappedDispatcher;

/**
* EventBus constructor.
*
* @param ContainerAwareDispatcher $wrappedDispatcher
* @param EventDispatcher $wrappedDispatcher
*/
public function __construct(EventDispatcher $wrappedDispatcher)
{
Expand All @@ -40,6 +40,6 @@ public function __construct(EventDispatcher $wrappedDispatcher)
*/
public function dispatch(Event $event): void
{
$this->wrappedDispatcher->dispatch(\get_class($event), new EventEnvelope($event));
$this->wrappedDispatcher->dispatch(new EventEnvelope($event));
}
}
9 changes: 9 additions & 0 deletions src/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@
namespace Gears\Event\Symfony\Dispatcher;

use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent;

interface EventDispatcher extends EventDispatcherInterface
{
/**
* Dispatches an event to all registered listeners.
*
* @param mixed $eventEnvelope
*
* @return SymfonyEvent
*/
public function dispatch($eventEnvelope): SymfonyEvent;
}
2 changes: 1 addition & 1 deletion src/EventEnvelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Gears\Event\Symfony\Dispatcher;

use Gears\Event\Event;
use Symfony\Component\EventDispatcher\Event as SymfonyEvent;
use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent;

final class EventEnvelope extends SymfonyEvent
{
Expand Down
Loading

0 comments on commit d810e4b

Please sign in to comment.