Skip to content

Commit dcc2920

Browse files
committed
update immutability dependency
1 parent 42b9af4 commit dcc2920

21 files changed

Lines changed: 91 additions & 81 deletions

.scrutinizer.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
# language: php
22

3+
build:
4+
dependencies:
5+
before:
6+
- 'composer self-update'
7+
- 'composer update --prefer-stable --prefer-source --no-interaction --no-progress --no-suggest'
8+
cache:
9+
directories:
10+
- vendor/
11+
nodes:
12+
analysis:
13+
project_setup:
14+
override: true
15+
tests:
16+
override: [php-scrutinizer-run]
17+
318
filter:
419
paths: [src/*]
520
excluded_paths: [tests/*, vendor/*]
621

7-
before_commands:
8-
- 'composer self-update'
9-
- 'composer update --prefer-stable --prefer-source --no-interaction --no-scripts --no-progress --no-suggest'
10-
1122
coding_style:
1223
php:
1324
upper_lower_casing:
@@ -17,8 +28,8 @@ coding_style:
1728
true_false_null: lower
1829
spaces:
1930
around_operators:
20-
concatenation: true
21-
negation: false
31+
concatenation: true
32+
negation: false
2233
other:
2334
after_type_cast: true
2435

@@ -34,7 +45,6 @@ tools:
3445
enabled: true
3546
config:
3647
ruleset: 'unusedcode,naming,design,controversial,codesize'
37-
3848
php_cpd: true
3949
php_loc: true
4050
php_pdepend: true

.travis.yml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ env:
1313
- COMPOSER_FLAGS="--prefer-stable --prefer-dist"
1414

1515
php:
16+
- 7.2
1617
- 7.3
18+
- 7.4snapshot
1719
- nightly
1820

1921
matrix:
@@ -22,25 +24,25 @@ matrix:
2224
- php: 7.1
2325
env:
2426
- COMPOSER_FLAGS="--prefer-lowest --prefer-stable --prefer-dist"
25-
- php: 7.2
27+
- php: 7.1
2628
env:
2729
- TEST_VERSION=true
2830
- COMPOSER_FLAGS="--prefer-stable --prefer-dist"
2931
allow_failures:
3032
- php: nightly
3133

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

3739
install:
38-
- travis_retry composer update $COMPOSER_FLAGS --no-interaction --no-scripts --no-progress
39-
- if [[ $TEST_VERSION ]]; then travis_retry composer require php-coveralls/php-coveralls $COMPOSER_FLAGS --no-interaction --no-scripts --no-progress ; fi
40+
- travis_retry composer update $COMPOSER_FLAGS --no-interaction --no-progress
41+
- if [[ $TEST_VERSION ]]; then travis_retry composer require php-coveralls/php-coveralls $COMPOSER_FLAGS --no-interaction --no-scripts --no-progress ; fi
4042

4143
script:
42-
- if [[ $TEST_VERSION ]]; then composer qa && composer report-phpunit-clover ; fi
43-
- if [[ -z $TEST_VERSION ]]; then composer test-phpunit ; fi
44+
- if [[ $TEST_VERSION ]]; then composer qa && composer report-phpunit-clover ; fi
45+
- if [[ -z $TEST_VERSION ]]; then composer test-phpunit ; fi
4446

4547
after_script:
46-
- if [[ $TEST_VERSION ]]; then travis_retry php vendor/bin/php-coveralls --verbose ; fi
48+
- if [[ $TEST_VERSION ]]; then travis_retry php vendor/bin/php-coveralls --verbose ; fi

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
Event base classes and handling interfaces
1616

17-
This package only provides the building blocks to Event
17+
This package only provides the building blocks to events
1818

1919
## Installation
2020

@@ -34,9 +34,9 @@ require './vendor/autoload.php';
3434

3535
### Events
3636

37-
Events are DTOs that carry all the information for an action to happen
37+
Events are DTOs that carry all the information of an already happened situation
3838

39-
You can create your own by implementing `Gears\Event\Event` or extending from `Gears\Event\AbstractEvent` which ensures event immutability and payload and metadata is composed only of **scalar values** which is a very interesting capability. AbstractEvent has a private constructor forcing you to create events using the _occurred_ static method
39+
You can create your own by implementing `Gears\Event\Event` or extending from `Gears\Event\AbstractEvent` which ensures event immutability and payload and metadata is composed only of **scalar values** which is a very interesting capability. AbstractEvent has a private constructor forcing you to create events using _occurred_ static method on your named constructors
4040

4141
```php
4242
use Gears\Event\AbstractEvent;
@@ -48,7 +48,7 @@ class CreateUserEvent extends AbstractEvent
4848
string lastname,
4949
\DateTimeImmutable $birthDate
5050
): self {
51-
return new occurred([
51+
return static::occurred([
5252
'name' => $name,
5353
'lastname' => $lastname,
5454
'birthDate' => $birthDate->format('U'),
@@ -72,7 +72,7 @@ class CreateUserEvent extends AbstractEmptyEvent
7272

7373
### Collection
7474

75-
Events can be grouped into iterables implementing `Gears\Event\EventCollection` objects, `Gears\Event\EventArrayCollection` is provided accepting only instances of `Gears\Event\Event`
75+
Events can be grouped into iterables implementing `Gears\Event\EventCollection` objects, `Gears\Event\EventArrayCollection` and `Gears\Event\EventIteratorCollection` are provided accepting only instances of `Gears\Event\Event`
7676

7777
#### Async events
7878

composer.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,23 @@
2424
"require": {
2525
"php": "^7.1",
2626
"myclabs/deep-copy": "^1.8",
27-
"phpgears/dto": "~0.2"
27+
"phpgears/dto": "~0.3"
2828
},
2929
"require-dev": {
3030
"brainmaestro/composer-git-hooks": "^2.1",
3131
"friendsofphp/php-cs-fixer": "^2.0",
3232
"infection/infection": "^0.9",
3333
"phpmd/phpmd": "^2.0",
34-
"phpstan/phpstan": "^0.10",
35-
"phpstan/phpstan-deprecation-rules": "^0.10",
36-
"phpstan/phpstan-strict-rules": "^0.10",
37-
"phpunit/phpunit": "^6.0|^7.0",
34+
"phpstan/extension-installer": "^1.0",
35+
"phpstan/phpstan": "~0.11.12",
36+
"phpstan/phpstan-deprecation-rules": "~0.11.2",
37+
"phpstan/phpstan-strict-rules": "~0.11.1",
38+
"phpunit/phpunit": "^7.0|^8.0",
3839
"povils/phpmnd": "^2.0",
3940
"roave/security-advisories": "dev-master",
40-
"sebastian/phpcpd": "^3.0|^4.0",
41-
"squizlabs/php_codesniffer": "^2.0",
42-
"thecodingmachine/phpstan-strict-rules": "^0.10.1"
41+
"sebastian/phpcpd": "^4.0",
42+
"squizlabs/php_codesniffer": "^3.0",
43+
"thecodingmachine/phpstan-strict-rules": "^0.10.2"
4344
},
4445
"suggest": {
4546
},

phpstan.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
includes:
2-
- vendor/phpstan/phpstan-strict-rules/rules.neon
3-
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
4-
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
5-
61
parameters:
72
level: max
83
paths:

src/AbstractEmptyEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abstract class AbstractEmptyEvent implements Event
3131
*/
3232
private function __construct(array $metadata, \DateTimeImmutable $createdAt)
3333
{
34-
$this->checkImmutability();
34+
$this->assertImmutable();
3535

3636
$this->setMetadata($metadata);
3737
$this->createdAt = $createdAt->setTimezone(new \DateTimeZone('UTC'));

src/AbstractEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract class AbstractEvent implements Event
3232
*/
3333
private function __construct(array $payload, array $metadata, \DateTimeImmutable $createdAt)
3434
{
35-
$this->checkImmutability();
35+
$this->assertImmutable();
3636

3737
$this->setPayload($payload);
3838
$this->setMetadata($metadata);

src/AbstractEventHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final public function handle(Event $event): void
2626
{
2727
if (!$this->isEventSupported($event)) {
2828
throw new InvalidEventException(\sprintf(
29-
'Event must be a %s, %s given',
29+
'Event must be a "%s", "%s" given',
3030
\implode('or ', $this->getSupportedEventTypes()),
3131
\get_class($event)
3232
));

src/EventArrayCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(array $events)
3434
foreach ($events as $event) {
3535
if (!$event instanceof Event) {
3636
throw new InvalidEventException(\sprintf(
37-
'Event collection only accepts %s, %s given',
37+
'Event collection only accepts "%s", "%s" given',
3838
Event::class,
3939
\is_object($event) ? \get_class($event) : \gettype($event)
4040
));

src/EventBehaviour.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private function setMetadata(array $parameters): void
8383
} catch (InvalidScalarParameterException $exception) {
8484
throw new InvalidScalarParameterException(
8585
\sprintf(
86-
'Class %s can only accept scalar metadata parameters, %s given',
86+
'Class "%s" can only accept scalar metadata parameters, "%s" given',
8787
self::class,
8888
\is_object($value) ? \get_class($value) : \gettype($value)
8989
),

0 commit comments

Comments
 (0)