diff --git a/src/Event/DefaultActionEvent.php b/src/Event/DefaultActionEvent.php index 1933528..6f79012 100644 --- a/src/Event/DefaultActionEvent.php +++ b/src/Event/DefaultActionEvent.php @@ -118,8 +118,8 @@ public function setTarget($target): void */ public function setParams($params): void { - if (! is_array($params) && ! $params instanceof \ArrayAccess) { - throw new \InvalidArgumentException('Event params are invalid. Expected type is array or \\ArrayAccess. Got ' . gettype($params)); + if (! \is_array($params) && ! $params instanceof \ArrayAccess) { + throw new \InvalidArgumentException('Event params are invalid. Expected type is array or \\ArrayAccess. Got ' . \gettype($params)); } $this->params = $params; diff --git a/src/Event/ProophActionEventEmitter.php b/src/Event/ProophActionEventEmitter.php index b7c7bf4..efbe6e3 100644 --- a/src/Event/ProophActionEventEmitter.php +++ b/src/Event/ProophActionEventEmitter.php @@ -88,7 +88,7 @@ public function dispatchUntil(ActionEvent $event, callable $callback): void */ public function attachListener(string $event, callable $listener, int $priority = 1): ListenerHandler { - if (! empty($this->availableEventNames) && ! in_array($event, $this->availableEventNames, true)) { + if (! empty($this->availableEventNames) && ! \in_array($event, $this->availableEventNames, true)) { throw new \InvalidArgumentException("Unknown event name given: $event"); } @@ -135,7 +135,7 @@ private function getListeners(ActionEvent $event): iterable { $prioritizedListeners = $this->events[$event->getName()] ?? []; - krsort($prioritizedListeners, SORT_NUMERIC); + \krsort($prioritizedListeners, SORT_NUMERIC); foreach ($prioritizedListeners as $listenersByPriority) { foreach ($listenersByPriority as $listenerHandler) { diff --git a/src/Messaging/DomainMessage.php b/src/Messaging/DomainMessage.php index 16c79ca..57921a8 100644 --- a/src/Messaging/DomainMessage.php +++ b/src/Messaging/DomainMessage.php @@ -49,7 +49,7 @@ public static function fromArray(array $messageData): DomainMessage { MessageDataAssertion::assert($messageData); - $messageRef = new \ReflectionClass(get_called_class()); + $messageRef = new \ReflectionClass(\get_called_class()); /** @var $message DomainMessage */ $message = $messageRef->newInstanceWithoutConstructor(); @@ -70,7 +70,7 @@ protected function init(): void } if ($this->messageName === null) { - $this->messageName = get_class($this); + $this->messageName = \get_class($this); } if ($this->createdAt === null) { diff --git a/src/Messaging/FQCNMessageFactory.php b/src/Messaging/FQCNMessageFactory.php index 48793b8..f5859db 100644 --- a/src/Messaging/FQCNMessageFactory.php +++ b/src/Messaging/FQCNMessageFactory.php @@ -20,12 +20,12 @@ class FQCNMessageFactory implements MessageFactory { public function createMessageFromArray(string $messageName, array $messageData): Message { - if (! class_exists($messageName)) { + if (! \class_exists($messageName)) { throw new \UnexpectedValueException('Given message name is not a valid class: ' . (string) $messageName); } - if (! is_subclass_of($messageName, DomainMessage::class)) { - throw new \UnexpectedValueException(sprintf( + if (! \is_subclass_of($messageName, DomainMessage::class)) { + throw new \UnexpectedValueException(\sprintf( 'Message class %s is not a sub class of %s', $messageName, DomainMessage::class diff --git a/src/Messaging/MessageDataAssertion.php b/src/Messaging/MessageDataAssertion.php index f3b3f19..ff299ec 100644 --- a/src/Messaging/MessageDataAssertion.php +++ b/src/Messaging/MessageDataAssertion.php @@ -59,7 +59,7 @@ public static function assertPayload($payload): void */ private static function assertSubPayload($payload): void { - if (is_array($payload)) { + if (\is_array($payload)) { foreach ($payload as $subPayload) { self::assertSubPayload($subPayload); } @@ -76,16 +76,16 @@ public static function assertMetadata($metadata): void foreach ($metadata as $key => $value) { Assertion::minLength($key, 1, 'A metadata key must be non empty string'); - Assertion::scalar($value, 'A metadata value must have a scalar type. Got ' . gettype($value) . ' for ' . $key); + Assertion::scalar($value, 'A metadata value must have a scalar type. Got ' . \gettype($value) . ' for ' . $key); } } public static function assertCreatedAt($createdAt): void { - Assertion::isInstanceOf($createdAt, DateTimeImmutable::class, sprintf( + Assertion::isInstanceOf($createdAt, DateTimeImmutable::class, \sprintf( 'created_at must be of type %s. Got %s', DateTimeImmutable::class, - is_object($createdAt) ? get_class($createdAt) : gettype($createdAt) + \is_object($createdAt) ? \get_class($createdAt) : \gettype($createdAt) )); } }