From 5a8eec012ab374acc990825a4ee3208bb84de770 Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Fri, 31 Oct 2025 17:59:34 +0200 Subject: [PATCH] Issue #36: Remove PHP 8.1 and add PHP 8.4 & 8.5 support Signed-off-by: alexmerlin --- .github/workflows/codecov.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- README.md | 2 +- SECURITY.md | 8 +++---- composer.json | 6 +++--- docs/book/v4/overview.md | 2 +- docs/book/v4/usage.md | 30 +++++++++++++-------------- 7 files changed, 24 insertions(+), 28 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 7ad749b..c0fbc53 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -15,10 +15,10 @@ jobs: - ubuntu-latest php: - - "8.1" - "8.2" - "8.3" - "8.4" + - "8.5" steps: - name: Checkout diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 03d62cb..9976515 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -15,10 +15,10 @@ jobs: - ubuntu-latest php: - - "8.1" - "8.2" - "8.3" - "8.4" + - "8.5" steps: - name: Checkout diff --git a/README.md b/README.md index 334773d..8ae8117 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Documentation is available at: https://docs.dotkernel.org/dot-event/. ## Badges ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-event) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-event/4.3.0) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-event/4.4.0) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-event)](https://github.com/dotkernel/dot-event/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-event)](https://github.com/dotkernel/dot-event/network) diff --git a/SECURITY.md b/SECURITY.md index 1304a0d..5b585ca 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,14 +2,12 @@ ## Supported Versions - | Version | Supported | PHP Version | |---------|--------------------|-----------------------------------------------------------------------------------------------------------| -| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-event/4.0.0) | -| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-event/3.4.2) | +| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-event/4.4.0) | +| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-event/3.5.0) | | <= 2.x | :x: | | - ## Reporting Potential Security Issues If you have encountered a potential security vulnerability in this project, @@ -25,7 +23,7 @@ When reporting issues, please provide the following information: We request that you contact us via the email address above and give the project contributors a chance to resolve the vulnerability and issue a new release prior to any public exposure; this helps protect the project's -users, and provides them with a chance to upgrade and/or update in order to +users and provides them with a chance to upgrade and/or update to protect their applications. diff --git a/composer.json b/composer.json index 1e8af4e..e9a7de1 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", "laminas/laminas-eventmanager": "^3.4", "laminas/laminas-servicemanager": "^3.10 || ^4.0", "psr/http-message": "^1.0 || ^2.0" @@ -46,8 +46,8 @@ ], "cs-check": "phpcs", "cs-fix": "phpcbf", - "test": "phpunit --colors=always", - "static-analysis": "phpstan analyse --memory-limit 1G" + "static-analysis": "phpstan analyse --memory-limit 1G", + "test": "phpunit --colors=always" }, "config": { "allow-plugins": { diff --git a/docs/book/v4/overview.md b/docs/book/v4/overview.md index ae361fd..79d86ef 100644 --- a/docs/book/v4/overview.md +++ b/docs/book/v4/overview.md @@ -7,7 +7,7 @@ Dotkernel's event manager package. ## Badges ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-event) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-event/4.3.0) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-event/4.4.0) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-event)](https://github.com/dotkernel/dot-event/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-event)](https://github.com/dotkernel/dot-event/network) diff --git a/docs/book/v4/usage.md b/docs/book/v4/usage.md index 18c650c..05fc943 100644 --- a/docs/book/v4/usage.md +++ b/docs/book/v4/usage.md @@ -2,19 +2,19 @@ This tutorial explores various examples of dot-event usages. -To start using events you will need the following things: +To start using events, you will need the following things: - An **Event** -- One or more **listeners** that will be registered on the application config ( ``ConfigProvider`` ) +- One or more **listeners** that will be registered on the application config (`ConfigProvider`) - An instance of **EventManager** from the **container** so you can trigger the events -The listeners needs to be registered in the `ConfigProvider`, under the `['dot-event']` key. +The listeners need to be registered in the `ConfigProvider`, under the `['dot-event']` key. ## Example The below example will implement an event for update users. -Every event needs to extends `Dot\Event\Event`: +Every event needs to extend `Dot\Event\Event`: ```php class UserEvent extends Event @@ -31,7 +31,7 @@ class UserEvent extends Event ``` We use the concept of listener aggregates because with this approach in a single class we can listen to multiple events. -If you pay attention, in the above event we have 2 events `pre.update.user` and `post.update.user`. +If you pay attention, in the above event we have two events `pre.update.user` and `post.update.user`. Every listener needs to extend `Dot\Event\ControllerEventListenerInterface`. The interface defines two methods `attach()` and `detach()`. @@ -110,10 +110,10 @@ class MyService You can attach multiple listeners to the same event but with different logic. -All listeners are executed in the order in which they are attached. However, you can provide a priority value and you can influence the order of the execution. +All listeners are executed in the order in which they are attached. However, you can provide a priority value, and you can influence the order of the execution. -- Higher priority values execute earlier. -- Lower (negative) priority values execute later. +- Higher priority values execute earlier +- Lower (negative) priority values execute later ```php class UserEventListener implements DotEventListenerInterface @@ -136,12 +136,12 @@ class UserEventListener implements DotEventListenerInterface } ``` -As you can notice, we attach the same event name to listeners, so once we trigger the event both callback will run one after another. -But because we provide priority, the second attach will run first because has a higher priority. +As you can notice, we attach the same event name to listeners, so once we trigger the event, both callbacks will run one after another. +But because we provide priority, the second attachment will run first because it has a higher priority. ## Short-circuiting the execution -Sometimes you have more listeners to an event, and you may want to stop the execution of the event if something is wrong in one of the listeners. +Sometimes you have more listeners to an event, and you may want to stop the execution of the event if something is wrong with one of the listeners. ```php @@ -152,15 +152,14 @@ Sometimes you have more listeners to an event, and you may want to stop the exec public function onUserPostUpdateSecond(UserEvent $event) { - // this will not execute - } ``` ## Returns -You can return whatever you want in a listener callback. All events trigger returns an instance of `Laminas\EventManager\ResponseCollection` so you can have information if the event has stopped, or if event returned some expected object. +You can return whatever you want in a listener callback. +All events trigger return an instance of `Laminas\EventManager\ResponseCollection` so you can have information if the event has stopped, or if event returned some expected object. ```php class MyService @@ -168,13 +167,12 @@ class MyService #[Dot\AnnotatedServices\Attribute\Inject(EventManagerInterface::class)] public function __construct(private EventManagerInterface $eventManager) { - } public function update() { /** @var Laminas\EventManager\ResponseCollection $result */ - $result = $this->eventManager->triggerEvent(new UserEvent(UserEvent::EVENTS_POST_UPDATE, params: ['user' => $user])); + $result = $this->eventManager->triggerEvent(new UserEvent(UserEvent::EVENTS_POST_UPDATE, params: ['user' => $user])); $result->stopped(); // true or false if propagation is stopped $result->first(); // what last listener has returned (on multiple listeners it uses LIFO mode) }