From c632bd12729f56f626024aede96467b96f6ad159 Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Tue, 18 Nov 2025 14:24:45 +0200 Subject: [PATCH] Issue #56: Remove PHP 8.1 and add PHP 8.4 & 8.5 support Signed-off-by: alexmerlin --- .github/workflows/codecov.yml | 4 +-- .github/workflows/static-analysis.yml | 4 +-- .laminas-ci.json | 3 +++ OSSMETADATA | 2 +- README.md | 2 +- SECURITY.md | 25 ++++++------------- composer.json | 14 +++++------ docs/book/v3/configuration.md | 4 ++- docs/book/v3/examples/example-date-ext.md | 18 +++++++------ .../examples/example-flash-messenger-ext.md | 19 +++++++------- .../v3/examples/example-form-elements-ext.md | 2 +- .../v3/examples/example-navigation-ext.md | 10 ++++---- .../v3/examples/example-translation-ext.md | 11 ++++---- docs/book/v3/installation.md | 4 ++- docs/book/v3/overview.md | 2 +- docs/book/v3/usage/factory.md | 15 ++--------- docs/book/v3/usage/injection.md | 6 ++--- 17 files changed, 67 insertions(+), 78 deletions(-) create mode 100644 .laminas-ci.json diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 190b4da..2f4aa24 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -15,13 +15,13 @@ jobs: - ubuntu-latest php: - - "8.1" - "8.2" - "8.3" + - "8.4" steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v5 - name: Install PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 2423564..dd89fbf 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -15,13 +15,13 @@ jobs: - ubuntu-latest php: - - "8.1" - "8.2" - "8.3" + - "8.4" steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Install PHP uses: shivammathur/setup-php@v2 diff --git a/.laminas-ci.json b/.laminas-ci.json new file mode 100644 index 0000000..29216fa --- /dev/null +++ b/.laminas-ci.json @@ -0,0 +1,3 @@ +{ + "backwardCompatibilityCheck": true +} diff --git a/OSSMETADATA b/OSSMETADATA index 6c7e106..b96d4a4 100644 --- a/OSSMETADATA +++ b/OSSMETADATA @@ -1 +1 @@ -osslifecycle=active \ No newline at end of file +osslifecycle=active diff --git a/README.md b/README.md index 90cc525..7f929ab 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Documentation is available at: https://docs.dotkernel.org/dot-twigrenderer/. ## Badges ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-twigrenderer) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-twigrenderer/3.6.0) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-twigrenderer/3.7.0) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-twigrenderer)](https://github.com/dotkernel/dot-twigrenderer/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-twigrenderer)](https://github.com/dotkernel/dot-twigrenderer/network) diff --git a/SECURITY.md b/SECURITY.md index d2e9839..92ba650 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,18 +2,15 @@ ## Supported Versions - | Version | Supported | PHP Version | |---------|--------------------|------------------------------------------------------------------------------------------------------------------| -| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-twigrenderer/3.4.3) | +| 3.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-twigrenderer/3.7.0) | | <= 2.x | :x: | | - ## Reporting Potential Security Issues -If you have encountered a potential security vulnerability in this project, -please report it to us at . We will work with you to -verify the vulnerability and patch it. +If you have encountered a potential security vulnerability in this project, please report it to us at . +We will work with you to verify the vulnerability and patch it. When reporting issues, please provide the following information: @@ -21,20 +18,12 @@ When reporting issues, please provide the following information: - A description indicating how to reproduce the issue - A summary of the security vulnerability and impact -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 -protect their applications. - +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 to protect their applications. ## Policy If we verify a reported security vulnerability, our policy is: -- We will patch the current release branch, as well as the immediate prior minor - release branch. - -- After patching the release branches, we will immediately issue new security - fix releases for each patched release branch. - +- We will patch the current release branch, as well as the immediate prior minor release branch. +- After patching the release branches, we will immediately issue new security fix releases for each patched release branch. diff --git a/composer.json b/composer.json index f626f30..c760338 100644 --- a/composer.json +++ b/composer.json @@ -16,15 +16,15 @@ } ], "require": { - "php": "~8.1.0 || ~8.2.0 || ~8.3.0", - "laminas/laminas-servicemanager": "^3.22.1", - "mezzio/mezzio-twigrenderer": "^2.15", - "laminas/laminas-view": "^2.33", - "laminas/laminas-authentication": "^2.16", - "dotkernel/dot-navigation": "^3.5.1", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0", + "dotkernel/dot-authorization": "^3.4.1", "dotkernel/dot-flashmessenger": "^3.4.2", + "dotkernel/dot-navigation": "^3.5.1", + "laminas/laminas-authentication": "^2.16", "laminas/laminas-form": "^3.19.1", - "dotkernel/dot-authorization": "^3.4.1" + "laminas/laminas-view": "^2.33", + "laminas/laminas-servicemanager": "^3.22.1", + "mezzio/mezzio-twigrenderer": "^2.15" }, "require-dev": { "laminas/laminas-coding-standard": "^3.0", diff --git a/docs/book/v3/configuration.md b/docs/book/v3/configuration.md index ebe3a80..6a72016 100644 --- a/docs/book/v3/configuration.md +++ b/docs/book/v3/configuration.md @@ -2,4 +2,6 @@ Register `dot-twigrenderer`'s ConfigProvider in your application's configurations by adding the following line to `config/config.php`: - \Dot\Twig\ConfigProvider::class, +```php +Dot\Twig\ConfigProvider::class, +``` diff --git a/docs/book/v3/examples/example-date-ext.md b/docs/book/v3/examples/example-date-ext.md index 882c10d..0dd6bda 100644 --- a/docs/book/v3/examples/example-date-ext.md +++ b/docs/book/v3/examples/example-date-ext.md @@ -1,13 +1,15 @@ # Using the date extension -Dot-twigrenderer extends Twig with a function that calculates the difference between two dates. The function converts dates to a time ago string like Facebook and Twitter has. If `null` is passed as the second or third parameters, the current time will be used. +Dot-twigrenderer extends Twig with a function that calculates the difference between two dates. +The function converts dates to a time ago string like Facebook and Twitter has. +If `null` is passed as the second or third parameters, the current time will be used. ```php public function diff( - Environment $env, - string|DateTimeInterface|null $date, - string|DateTimeZone|null $now = null - ): string; + Environment $env, + string|DateTimeInterface|null $date, + string|DateTimeZone|null $now = null, +): string; ``` ## Example usage @@ -19,9 +21,9 @@ $loader = new \Twig\Loader\FilesystemLoader(__DIR__ . '/../../templates/page'); $twigEnv = new \Twig\Environment($loader); $this->template->render('page::templateName', [ - "env" => $twigEnv, - #other parameters - ]); + 'env' => $twigEnv, + #other parameters +]); ``` This enables the use of the `diff` function: diff --git a/docs/book/v3/examples/example-flash-messenger-ext.md b/docs/book/v3/examples/example-flash-messenger-ext.md index adf1436..12e2b46 100644 --- a/docs/book/v3/examples/example-flash-messenger-ext.md +++ b/docs/book/v3/examples/example-flash-messenger-ext.md @@ -4,19 +4,20 @@ Dot-twigrenderer extends Twig with functions that use functionality from [dotker ```php public function renderMessages( - ?string $type = null, - string $channel = FlashMessengerInterface::DEFAULT_CHANNEL - ): string; // empty response + ?string $type = null, + string $channel = FlashMessengerInterface::DEFAULT_CHANNEL +): string; // empty response public function function renderMessagesPartial( - string $partial, - array $params = [], - ?string $type = null, - string $channel = FlashMessengerInterface::DEFAULT_CHANNEL - ): string; + string $partial, + array $params = [], + ?string $type = null, + string $channel = FlashMessengerInterface::DEFAULT_CHANNEL +): string; ``` -`renderMessagesPartial` returns messages previously passed to `dot-flashMessenger`. The last 3 parameters can be omitted to list all messages sent to FlashMessenger. +`renderMessagesPartial` returns messages previously passed to `dot-flashMessenger`. +The last three parameters can be omitted to list all messages sent to FlashMessenger. * `$partial` is the template file name * `$params` is an optional array of items (key-value) passed to the template file diff --git a/docs/book/v3/examples/example-form-elements-ext.md b/docs/book/v3/examples/example-form-elements-ext.md index 57adcd3..0aec957 100644 --- a/docs/book/v3/examples/example-form-elements-ext.md +++ b/docs/book/v3/examples/example-form-elements-ext.md @@ -1,6 +1,6 @@ # Using the form elements extension -Dot-twigrenderer extends Twig with a function based on `TwigTest` that checks if each `Form` element is an instance of its class. +DotTwigrenderer extends Twig with a function based on `TwigTest` that checks if each `Form` element is an instance of its class. ```php public function getTests(): array; diff --git a/docs/book/v3/examples/example-navigation-ext.md b/docs/book/v3/examples/example-navigation-ext.md index 5af31ee..bb7d8cd 100644 --- a/docs/book/v3/examples/example-navigation-ext.md +++ b/docs/book/v3/examples/example-navigation-ext.md @@ -5,13 +5,13 @@ Dot-twigrenderer extends Twig with functions that use functionality from [dotker ```php public function htmlAttributes(Page $page): string; -public function renderMenu(NavigationContainer|string $container): string; //incomplete? +public function renderMenu(NavigationContainer|string $container): string; public function renderMenuPartial( - NavigationContainer|string $container, - string $partial, - array $params = [] - ): string; + NavigationContainer|string $container, + string $partial, + array $params = [] +): string; ``` * `$partial` is the template file name diff --git a/docs/book/v3/examples/example-translation-ext.md b/docs/book/v3/examples/example-translation-ext.md index 3ffa70b..ef0e361 100644 --- a/docs/book/v3/examples/example-translation-ext.md +++ b/docs/book/v3/examples/example-translation-ext.md @@ -1,16 +1,17 @@ # Using the translation extension -Dot-twigrenderer extends Twig with a filter called `trans` that parses translations in singular and plural forms. +DotTwigrenderer extends Twig with a filter called `trans` that parses translations in singular and plural forms. -The `local.php.dist` file in [frontend](https://github.com/dotkernel/frontend/blob/4.0/config/autoload/local.php.dist) provides an example for working with multiple languages. The `translator` variable can be expanded to other languages using [Poedit](https://poedit.net/) which can edit `.po` files like the example in `data/language/da_DK/LC_MESSAGES/messages.po`. The compiled file will have the extension `.mo` +The `local.php.dist` file in [frontend](https://github.com/dotkernel/frontend/blob/4.0/config/autoload/local.php.dist) provides an example for working with multiple languages. +The `translator` variable can be expanded to other languages using [Poedit](https://poedit.net/) which can edit `.po` files like the example in `data/language/da_DK/LC_MESSAGES/messages.po`. +The compiled file will have the extension `.mo`. To apply the translations - the Twig templates need either `{% trans 'translateText' %}` or `{{ translateText|trans }}` -- then the js file needs `translateText("translateText")` +- then the JavaScript file needs `translateText("translateText")` -**NOTE:** -In order to have a proper behaviour of language selector, you need the language pack installed at the Operating System level. +> To have a proper behavior of language selector, you need the language pack installed at the Operating System level. `dnf install glibc-all-langpacks` diff --git a/docs/book/v3/installation.md b/docs/book/v3/installation.md index 30c27d9..5416a4b 100644 --- a/docs/book/v3/installation.md +++ b/docs/book/v3/installation.md @@ -2,4 +2,6 @@ Run the following command in your project folder - composer require dotkernel/dot-twigrenderer +```shell +composer require dotkernel/dot-twigrenderer +``` diff --git a/docs/book/v3/overview.md b/docs/book/v3/overview.md index fecef83..ef0187e 100644 --- a/docs/book/v3/overview.md +++ b/docs/book/v3/overview.md @@ -7,7 +7,7 @@ Dotkernel component providing Twig extensions and customizations. ## Badges ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-twigrenderer) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-twigrenderer/3.6.0) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-twigrenderer/3.7.0) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-twigrenderer)](https://github.com/dotkernel/dot-twigrenderer/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-twigrenderer)](https://github.com/dotkernel/dot-twigrenderer/network) diff --git a/docs/book/v3/usage/factory.md b/docs/book/v3/usage/factory.md index b37da4f..791f071 100644 --- a/docs/book/v3/usage/factory.md +++ b/docs/book/v3/usage/factory.md @@ -1,12 +1,10 @@ -# Method #1 - Factory +# Method #1: Factory ## Step 1: Create a factory that retrieves the SessionManger from the container ```php class ExampleFactory { - // code - public function __invoke(ContainerInterface $container) { return new ExampleService( @@ -19,7 +17,6 @@ class ExampleFactory ## Step 2: Access through your Service ```php - class ExampleService { private TemplateRendererInterface $template; @@ -28,8 +25,6 @@ class ExampleService { $this->template = $template; } - - //your methods } ``` @@ -39,15 +34,9 @@ Open the ConfigProvider of the module where your repository resides. Add a new entry under `factories`, where the key is your service's FQCN and the value is your factory's FQCN. -See below example for a better understanding of the file structure. +See the below example for a better understanding of the file structure. ```php -