From 897dc37004c0165c721dc4a1cc78482ca3abd861 Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Mon, 3 Nov 2025 11:59:03 +0200 Subject: [PATCH] Issue #60: Remove PHP 8.1 and add PHP 8.4 & 8.5 support Signed-off-by: alexmerlin --- .github/workflows/codecov.yml | 1 + .github/workflows/static-analysis.yml | 1 + README.md | 14 ++--- SECURITY.md | 25 +++------ composer.json | 6 +- docs/book/v4/cache.md | 4 +- docs/book/v4/factories.md | 6 +- docs/book/v4/factories/repository.md | 2 +- docs/book/v4/factories/service.md | 2 +- docs/book/v4/overview.md | 2 +- docs/book/v5/configuration.md | 7 --- docs/book/v5/factories.md | 30 ---------- docs/book/v5/factories/repository.md | 55 ------------------ docs/book/v5/factories/service.md | 80 --------------------------- docs/book/v5/installation.md | 7 --- docs/book/v5/overview.md | 9 --- docs/book/v5/usage.md | 8 --- mkdocs.yml | 10 ---- 18 files changed, 27 insertions(+), 242 deletions(-) delete mode 100644 docs/book/v5/configuration.md delete mode 100644 docs/book/v5/factories.md delete mode 100644 docs/book/v5/factories/repository.md delete mode 100644 docs/book/v5/factories/service.md delete mode 100644 docs/book/v5/installation.md delete mode 100644 docs/book/v5/overview.md delete mode 100644 docs/book/v5/usage.md diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 32a1a00..c0fbc53 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -18,6 +18,7 @@ jobs: - "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 dc4b6fa..9976515 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -18,6 +18,7 @@ jobs: - "8.2" - "8.3" - "8.4" + - "8.5" steps: - name: Checkout diff --git a/README.md b/README.md index ee8e997..3261ef8 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ Dotkernel component used to create services through [Laminas Service Manager](https://github.com/laminas/laminas-servicemanager) and inject them with dependencies just using method annotations. It can also create services without the need to write factories. -Annotation parsing can be cached, to improve performance. +Annotation parsing can be cached to improve performance. -This package can clean up your code, by getting rid of all the factories you write, sometimes just to inject a dependency or two. +This package can clean up your code by getting rid of all the factories you write, sometimes just to inject a dependency or two. ## Documentation @@ -13,7 +13,7 @@ Documentation is available at: https://docs.dotkernel.org/dot-annotated-services ## Badges ![OSS Lifecycle](https://img.shields.io/osslifecycle?file_url=https%3A%2F%2Fgithub.com%2Fdotkernel%2Fdot-annotated-services%2Fblob%2F4.0%2FOSSMETADATA) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.3.0) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.4.0) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-annotated-services)](https://github.com/dotkernel/dot-annotated-services/network) @@ -73,7 +73,7 @@ public function __construct( The annotation `@Inject` is telling the factory to inject the services between curly braces. Valid service names should be provided, as registered in the service manager. -To inject an array value from the service manager, you can use dot notation as below, +To inject an array value from the service manager, you can use dot notation as below. ```php use Dot\AnnotatedServices\Annotation\Inject; @@ -87,7 +87,7 @@ which will inject `$container->get('config')['debug'];` > Even if using dot annotation, the annotated factory will check first if a service name exists with that name. -You can use the inject annotation on setters too, they will be called at creation time and injected with the configured dependencies. +You can use the `@Inject` annotation on setters too, they will be called at creation time and injected with the configured dependencies. ### Using the AnnotatedRepositoryFactory @@ -123,7 +123,7 @@ class ExampleRepository extends EntityRepository Using this approach, no service manager configuration is required. It uses the registered abstract factory to create annotated services. -In order to tell the abstract factory which services are to be created, you need to annotate the service class with the `@Service` annotation. +To tell the abstract factory which services are to be created, you need to annotate the service class with the `@Service` annotation. ```php use Dot\AnnotatedServices\Annotation\Service; @@ -142,7 +142,7 @@ And that's it, you don't need to configure the service manager with this class, ## Cache annotations This package is built on top of `doctrine/annotation` and `doctrine/cache`. -In order to cache annotations, you should register a service factory at key `AbstractAnnotatedFactory::CACHE_SERVICE` that should return a valid `Doctrine\Common\Cache\Cache` cache driver. +To cache annotations, you should register a service factory at key `AbstractAnnotatedFactory::CACHE_SERVICE` that should return a valid `Doctrine\Common\Cache\Cache` cache driver. See [Cache Drivers](https://github.com/doctrine/cache/tree/master/lib/Doctrine/Common/Cache) for available implementations offered by doctrine. Below, we give an example, as defined in our frontend and admin starter applications: diff --git a/SECURITY.md b/SECURITY.md index 4fd00df..bb91681 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,19 +2,15 @@ ## Supported Versions - | Version | Supported | PHP Version | |---------|--------------------|------------------------------------------------------------------------------------------------------------------------| -| 5.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/5.2.0) | -| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.2.0) | +| 4.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-annotated-services/4.4.0) | | <= 3.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: @@ -22,19 +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 1be1d4b..1f70e67 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "service-manager" ], "require": { - "php": "~8.2.0 || ~8.3.0 || ~8.4.0", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", "doctrine/annotations": "^1.14.3", "doctrine/cache": "^1.12.1 || ^2.1.1", "doctrine/orm" : "^2.20", @@ -50,8 +50,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": { "sort-packages": true, diff --git a/docs/book/v4/cache.md b/docs/book/v4/cache.md index 4d6e6f4..8be24ba 100644 --- a/docs/book/v4/cache.md +++ b/docs/book/v4/cache.md @@ -4,11 +4,11 @@ ## Configuration -In order to cache annotations, you should register a service factory at key `AbstractAnnotatedFactory::CACHE_SERVICE` that should return a valid `Doctrine\Common\Cache\Cache` cache driver. +To cache annotations, you should register a service factory at key `AbstractAnnotatedFactory::CACHE_SERVICE` that should return a valid `Doctrine\Common\Cache\Cache` cache driver. See [Cache Drivers](https://github.com/doctrine/cache/tree/1.13.x/lib/Doctrine/Common/Cache) for available implementations offered by doctrine. See below an example on how you can configure `dot-annotated-services` to cache annotations. -You can add this configuration values to your application's Doctrine config file: +You can add this configuration value to your application's Doctrine config file: ```php 'annotations_cache_dir' => __DIR__ . '/../../data/cache/annotations', diff --git a/docs/book/v4/factories.md b/docs/book/v4/factories.md index 2f82c12..aa0141e 100644 --- a/docs/book/v4/factories.md +++ b/docs/book/v4/factories.md @@ -1,6 +1,6 @@ # Factories -`dot-annotated-services` is based on 3 reusable factories - `AnnotatedRepositoryFactory`, `AnnotatedServiceFactory` and `AnnotatedServiceAbstractFactory` - able to inject any dependency into a class. +`dot-annotated-services` is based on three reusable factories - `AnnotatedRepositoryFactory`, `AnnotatedServiceFactory` and `AnnotatedServiceAbstractFactory` - able to inject any dependency into a class. ## AttributedRepositoryFactory @@ -21,7 +21,7 @@ Injects class dependencies into classes. If a dependency is specified using the dot notation, `AttributedServiceFactory` will try to load a service having that specific alias. If it does not find one, it will try to load the dependency as a config tree, checking each segment if it's available in the service container. -You can use the inject annotation on setters too, they will be called at creation time and injected with the configured dependencies. +You can use the `@Inject` annotation on setters too, they will be called at creation time and injected with the configured dependencies. ### Exceptions thrown @@ -35,7 +35,7 @@ You can use the inject annotation on setters too, they will be called at creatio Using this approach, no service manager configuration is required. It uses the registered abstract factory to create annotated services. -In order to tell the abstract factory which services are to be created, you need to annotate the service class with the `@Service` annotation. +To tell the abstract factory which services are to be created, you need to annotate the service class with the `@Service` annotation. ```php $this->getDependencies(), - ]; - } - - public function getDependencies(): array - { - return [ - 'factories' => [ - YourApp\Repository\ExampleRepository::class => Dot\AnnotatedServices\Factory\AttributedRepositoryFactory::class, - ], - ]; - } -} -``` diff --git a/docs/book/v5/factories/service.md b/docs/book/v5/factories/service.md deleted file mode 100644 index c8ad182..0000000 --- a/docs/book/v5/factories/service.md +++ /dev/null @@ -1,80 +0,0 @@ -# Inject class dependencies - -## Prepare class - -`dot-annotated-services` determines the dependencies by looking at the `#[Inject]` attribute, added to the constructor of a class. -Dependencies are specified as separate parameters of the #[Inject] attribute. - -```php - $this->getDependencies(), - ]; - } - - public function getDependencies(): array - { - return [ - 'factories' => [ - YourApp\Service\Example::class => Dot\AnnotatedServices\Factory\AttributedServiceFactory::class, - ], - ]; - } -} -``` diff --git a/docs/book/v5/installation.md b/docs/book/v5/installation.md deleted file mode 100644 index 13b0b2a..0000000 --- a/docs/book/v5/installation.md +++ /dev/null @@ -1,7 +0,0 @@ -# Installation - -Install `dotkernel/dot-annotated-services` by executing the following Composer command: - -```shell -composer require dotkernel/dot-annotated-services -``` diff --git a/docs/book/v5/overview.md b/docs/book/v5/overview.md deleted file mode 100644 index e75266d..0000000 --- a/docs/book/v5/overview.md +++ /dev/null @@ -1,9 +0,0 @@ -# Overview - -`dot-annotated-services` is Dotkernel's dependency injection service. - -By providing reusable factories for service and repository injection, it reduces code complexity in projects. - -> `dot-annotated-services` v5 has been abandoned in favor of [dot-dependency-injection](https://github.com/dotkernel/dot-dependency-injection), which uses PHP attributes instead of annotations. -> -> Going forward, if you want to use annotations in your projects, use [dot-annotated-services v4](../v4/overview.md), else use `dot-dependency-injection`. diff --git a/docs/book/v5/usage.md b/docs/book/v5/usage.md deleted file mode 100644 index d2702b4..0000000 --- a/docs/book/v5/usage.md +++ /dev/null @@ -1,8 +0,0 @@ -# Usage - -Starting from version `5.x`, `dot-annotated-services` uses PHP attributes to inject dependencies. - -You can use it to: - -- [Inject class dependencies](factories/service.md) -- [Inject entity repositories](factories/repository.md) diff --git a/mkdocs.yml b/mkdocs.yml index 60afd92..ae5f3d8 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -4,19 +4,9 @@ extra: project: Packages current_version: v4 versions: - - v5 - v4 nav: - Home: index.md - - v5: - - Overview: v5/overview.md - - Installation: v5/installation.md - - Configuration: v5/configuration.md - - Usage: v5/usage.md - - Factories: v5/factories.md - - Reference: - - "Inject class dependencies": v5/factories/service.md - - "Inject entity repositories": v5/factories/repository.md - v4: - Overview: v4/overview.md - Installation: v4/installation.md