Skip to content

Commit

Permalink
end exception messages with period
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangut committed Nov 24, 2020
1 parent 73d33b8 commit aa8e268
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 35 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ matrix:

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

install:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Latest Version](https://img.shields.io/packagist/v/phpgears/event.svg?style=flat-square)](https://packagist.org/packages/phpgears/event)
[![License](https://img.shields.io/github/license/phpgears/event.svg?style=flat-square)](https://github.com/phpgears/event/blob/master/LICENSE)

[![Build Status](https://img.shields.io/travis/phpgears/event.svg?style=flat-square)](https://travis-ci.org/phpgears/event)
[![Build Status](https://img.shields.io/travis/com/phpgears/event.svg?style=flat-square)](https://travis-ci.com/github/phpgears/event)
[![Style Check](https://styleci.io/repos/149037486/shield)](https://styleci.io/repos/149037486)
[![Code Quality](https://img.shields.io/scrutinizer/g/phpgears/event.svg?style=flat-square)](https://scrutinizer-ci.com/g/phpgears/event)
[![Code Coverage](https://img.shields.io/coveralls/phpgears/event.svg?style=flat-square)](https://coveralls.io/github/phpgears/event)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.8",
"friendsofphp/php-cs-fixer": "^2.16",
"infection/infection": "^0.13|^0.15",
"infection/infection": "^0.13|^0.15|^0.18|^0.19",
"overtrue/phplint": "^1.2",
"pedrotroller/php-cs-custom-fixer": "^2.19",
"phpmd/phpmd": "^2.8",
Expand Down
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ parameters:
ignoreErrors:
- message: '/^Call to an undefined method DateTimeInterface::setTimezone\(\)\.$/'
path: src/Time/FixedTimeProvider.php
- message: '/^Method Gears\\Event\\EventArrayCollection::current\(\) should return Gears\\Event\\Event but returns Gears\\Event\\Event\|false\.$/'
path: src/EventArrayCollection.php
- message: '/^Unsafe usage of new static\(\)\.$/'
paths:
- src/AbstractEmptyEvent.php
Expand Down
8 changes: 4 additions & 4 deletions src/AbstractEmptyEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static function reconstitute(array $payload, \DateTimeImmutable $createdA
*/
final public function __serialize(): array
{
throw new EventException(\sprintf('Event "%s" cannot be serialized', static::class));
throw new EventException(\sprintf('Event "%s" cannot be serialized.', static::class));
}

/**
Expand All @@ -91,20 +91,20 @@ final public function __serialize(): array
*/
final public function __unserialize(array $data): void
{
throw new EventException(\sprintf('Event "%s" cannot be unserialized', static::class));
throw new EventException(\sprintf('Event "%s" cannot be unserialized.', static::class));
}

/**
* @return string[]
*/
final public function __sleep(): array
{
throw new EventException(\sprintf('Event "%s" cannot be serialized', static::class));
throw new EventException(\sprintf('Event "%s" cannot be serialized.', static::class));
}

final public function __wakeup(): void
{
throw new EventException(\sprintf('Event "%s" cannot be unserialized', static::class));
throw new EventException(\sprintf('Event "%s" cannot be unserialized.', static::class));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/AbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,20 @@ public static function reconstitute(array $payload, \DateTimeImmutable $createdA
*/
final public function __sleep(): array
{
throw new EventException(\sprintf('Event "%s" cannot be serialized', static::class));
throw new EventException(\sprintf('Event "%s" cannot be serialized.', static::class));
}

final public function __wakeup(): void
{
throw new EventException(\sprintf('Event "%s" cannot be unserialized', static::class));
throw new EventException(\sprintf('Event "%s" cannot be unserialized.', static::class));
}

/**
* @return array<string, mixed>
*/
final public function __serialize(): array
{
throw new EventException(\sprintf('Event "%s" cannot be serialized', static::class));
throw new EventException(\sprintf('Event "%s" cannot be serialized.', static::class));
}

/**
Expand All @@ -105,7 +105,7 @@ final public function __serialize(): array
*/
final public function __unserialize(array $data): void
{
throw new EventException(\sprintf('Event "%s" cannot be unserialized', static::class));
throw new EventException(\sprintf('Event "%s" cannot be unserialized.', static::class));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractEventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final public function handle(Event $event): void
{
if (!\in_array($event->getEventType(), $this->getSupportedEventTypes(), true)) {
throw new InvalidEventException(\sprintf(
'Event handler "%s" can only handle events of: "%s", "%s" given',
'Event handler "%s" can only handle events of: "%s", "%s" given.',
static::class,
\implode('"or "', $this->getSupportedEventTypes()),
\get_class($event)
Expand Down
10 changes: 5 additions & 5 deletions src/EventArrayCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(array $events)
foreach ($events as $event) {
if (!$event instanceof Event) {
throw new InvalidEventException(\sprintf(
'Event collection only accepts "%s", "%s" given',
'Event collection only accepts "%s", "%s" given.',
Event::class,
\is_object($event) ? \get_class($event) : \gettype($event)
));
Expand Down Expand Up @@ -105,20 +105,20 @@ public function count(): int
*/
public function __sleep(): array
{
throw new EventException(\sprintf('Event collection "%s" cannot be serialized', self::class));
throw new EventException(\sprintf('Event collection "%s" cannot be serialized.', self::class));
}

public function __wakeup(): void
{
throw new EventException(\sprintf('Event collection "%s" cannot be unserialized', self::class));
throw new EventException(\sprintf('Event collection "%s" cannot be unserialized.', self::class));
}

/**
* @return array<string, mixed>
*/
public function __serialize(): array
{
throw new EventException(\sprintf('Event collection "%s" cannot be serialized', self::class));
throw new EventException(\sprintf('Event collection "%s" cannot be serialized.', self::class));
}

/**
Expand All @@ -128,6 +128,6 @@ public function __serialize(): array
*/
public function __unserialize(array $data): void
{
throw new EventException(\sprintf('Event collection "%s" cannot be unserialized', self::class));
throw new EventException(\sprintf('Event collection "%s" cannot be unserialized.', self::class));
}
}
2 changes: 1 addition & 1 deletion src/EventBehaviour.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function addMetadata(array $metadata): void
} catch (InvalidScalarParameterException $exception) {
throw new InvalidScalarParameterException(
\sprintf(
'Class "%s" can only accept scalar metadata parameters, "%s" given',
'Class "%s" can only accept scalar metadata parameters, "%s" given.',
static::class,
\is_object($value) ? \get_class($value) : \gettype($value)
),
Expand Down
10 changes: 5 additions & 5 deletions src/EventIteratorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function current(): Event

if (!$event instanceof Event) {
throw new InvalidEventException(\sprintf(
'Event collection only accepts "%s", "%s" given',
'Event collection only accepts "%s", "%s" given.',
Event::class,
\is_object($event) ? \get_class($event) : \gettype($event)
));
Expand Down Expand Up @@ -127,20 +127,20 @@ public function count(): int
*/
public function __sleep(): array
{
throw new EventException(\sprintf('Event collection "%s" cannot be serialized', self::class));
throw new EventException(\sprintf('Event collection "%s" cannot be serialized.', self::class));
}

public function __wakeup(): void
{
throw new EventException(\sprintf('Event collection "%s" cannot be unserialized', self::class));
throw new EventException(\sprintf('Event collection "%s" cannot be unserialized.', self::class));
}

/**
* @return array<string, mixed>
*/
public function __serialize(): array
{
throw new EventException(\sprintf('Event collection "%s" cannot be serialized', self::class));
throw new EventException(\sprintf('Event collection "%s" cannot be serialized.', self::class));
}

/**
Expand All @@ -150,6 +150,6 @@ public function __serialize(): array
*/
public function __unserialize(array $data): void
{
throw new EventException(\sprintf('Event collection "%s" cannot be unserialized', self::class));
throw new EventException(\sprintf('Event collection "%s" cannot be unserialized.', self::class));
}
}
4 changes: 2 additions & 2 deletions tests/Event/AbstractEmptyEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ public function testReconstitute(): void
public function testNoSerialization(): void
{
$this->expectException(EventException::class);
$this->expectExceptionMessage('Event "Gears\Event\Tests\Stub\AbstractEmptyEventStub" cannot be serialized');
$this->expectExceptionMessage('Event "Gears\Event\Tests\Stub\AbstractEmptyEventStub" cannot be serialized.');

\serialize(AbstractEmptyEventStub::instance());
}

public function testNoDeserialization(): void
{
$this->expectException(EventException::class);
$this->expectExceptionMessage('Event "Gears\Event\Tests\Stub\AbstractEmptyEventStub" cannot be unserialized');
$this->expectExceptionMessage('Event "Gears\Event\Tests\Stub\AbstractEmptyEventStub" cannot be unserialized.');

\unserialize('O:45:"Gears\Event\Tests\Stub\AbstractEmptyEventStub":0:{}');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Event/AbstractEventHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testInvalidEventType(): void
{
$this->expectException(InvalidEventException::class);
$this->expectExceptionMessageRegExp(
'/^Event handler ".+" can only handle events of: ".+\\\AbstractEventStub", ".+" given$/'
'/^Event handler ".+" can only handle events of: ".+\\\AbstractEventStub", ".+" given\.$/'
);

$handler = new AbstractEventHandlerStub();
Expand Down
4 changes: 2 additions & 2 deletions tests/Event/AbstractEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public function testReconstitute(): void
public function testNoSerialization(): void
{
$this->expectException(EventException::class);
$this->expectExceptionMessage('Event "Gears\Event\Tests\Stub\AbstractEventStub" cannot be serialized');
$this->expectExceptionMessage('Event "Gears\Event\Tests\Stub\AbstractEventStub" cannot be serialized.');

\serialize(AbstractEventStub::instance([]));
}

public function testNoDeserialization(): void
{
$this->expectException(EventException::class);
$this->expectExceptionMessage('Event "Gears\Event\Tests\Stub\AbstractEventStub" cannot be unserialized');
$this->expectExceptionMessage('Event "Gears\Event\Tests\Stub\AbstractEventStub" cannot be unserialized.');

\unserialize('O:40:"Gears\Event\Tests\Stub\AbstractEventStub":0:{}');
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Event/EventArrayCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EventArrayCollectionTest extends TestCase
public function testInvalidTypeCollection(): void
{
$this->expectException(InvalidEventException::class);
$this->expectExceptionMessageRegExp('/^Event collection only accepts ".+", "string" given$/');
$this->expectExceptionMessageRegExp('/^Event collection only accepts ".+", "string" given\.$/');

new EventArrayCollection(['event']);
}
Expand Down Expand Up @@ -60,15 +60,15 @@ public function testCollectionCountEmpty(): void
public function testNoSerialization(): void
{
$this->expectException(EventException::class);
$this->expectExceptionMessage('Event collection "Gears\Event\EventArrayCollection" cannot be serialized');
$this->expectExceptionMessage('Event collection "Gears\Event\EventArrayCollection" cannot be serialized.');

\serialize(new EventArrayCollection([]));
}

public function testNoDeserialization(): void
{
$this->expectException(EventException::class);
$this->expectExceptionMessage('Event collection "Gears\Event\EventArrayCollection" cannot be unserialized');
$this->expectExceptionMessage('Event collection "Gears\Event\EventArrayCollection" cannot be unserialized.');

\unserialize('O:32:"Gears\Event\EventArrayCollection":0:{}');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Event/EventBehaviourTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testInvalidMetadata(): void
{
$this->expectException(InvalidScalarParameterException::class);
$this->expectExceptionMessageRegExp(
'/^Class ".+" can only accept scalar metadata parameters, "stdClass" given$/'
'/^Class ".+" can only accept scalar metadata parameters, "stdClass" given\.$/'
);

new EventBehaviourStub(['file' => new \stdClass()]);
Expand Down
6 changes: 3 additions & 3 deletions tests/Event/EventIteratorCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class EventIteratorCollectionTest extends TestCase
public function testInvalidTypeCollection(): void
{
$this->expectException(InvalidEventException::class);
$this->expectExceptionMessageRegExp('/^Event collection only accepts ".+", "string" given$/');
$this->expectExceptionMessageRegExp('/^Event collection only accepts ".+", "string" given\.$/');

(new EventIteratorCollection(new \ArrayIterator(['event'])))->current();
}
Expand Down Expand Up @@ -74,15 +74,15 @@ public function testCollectionCountNonCountable(): void
public function testNoSerialization(): void
{
$this->expectException(EventException::class);
$this->expectExceptionMessage('Event collection "Gears\Event\EventIteratorCollection" cannot be serialized');
$this->expectExceptionMessage('Event collection "Gears\Event\EventIteratorCollection" cannot be serialized.');

\serialize(new EventIteratorCollection(new \EmptyIterator()));
}

public function testNoDeserialization(): void
{
$this->expectException(EventException::class);
$this->expectExceptionMessage('Event collection "Gears\Event\EventIteratorCollection" cannot be unserialized');
$this->expectExceptionMessage('Event collection "Gears\Event\EventIteratorCollection" cannot be unserialized.');

\unserialize('O:35:"Gears\Event\EventIteratorCollection":0:{}');
}
Expand Down

0 comments on commit aa8e268

Please sign in to comment.