diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 26f124b..97589f2 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 a4deca7..2a7cd92 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Documentation is available at: https://docs.dotkernel.org/dot-dependency-injecti ## Badges ![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-dependency-injection) -![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-dependency-injection/1.2.0) +![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-dependency-injection/1.3.0) [![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-dependency-injection)](https://github.com/dotkernel/dot-dependency-injection/issues) [![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-dependency-injection)](https://github.com/dotkernel/dot-dependency-injection/network) @@ -31,8 +31,7 @@ Install `dot-dependency-injection` by running the following command in your proj composer require dotkernel/dot-dependency-injection ``` -After installing, register `dot-dependency-injection` in your project by adding the below line to your configuration -aggregate (usually: `config/config.php`): +After installing, register `dot-dependency-injection` in your project by adding the below line to your configuration aggregate (usually: `config/config.php`): ```php Dot\DependencyInjection\ConfigProvider::class, @@ -52,16 +51,12 @@ return [ ]; ``` -### NOTE - > You can use only the fully qualified class name as the service key The next step is to add the `#[Inject]` attribute to the service constructor with the service FQCNs to inject: -use Dot\DependencyInjection\Attribute\Inject; - ```php -#[Inject( +#[\Dot\DependencyInjection\Attribute\Inject( App\Srevice\Dependency1::class, App\Srevice\Dependency2::class, "config", @@ -79,18 +74,14 @@ 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 -use Dot\DependencyInjection\Attribute\Inject; - ```php -#[Inject( +#[\Dot\DependencyInjection\Attribute\Inject( "config.debug", )] ``` which will inject `$container->get('config')['debug'];`. -### NOTE - > Even if using dot notation, `AttributedServiceFactory` will check first if a service name exists with that name. ### Using the AttributedRepositoryFactory @@ -124,4 +115,4 @@ class ExampleRepository extends EntityRepository > Dependencies injected via the`#[Entity]`/`#[Inject]` attributes are not cached -> Injecting dependencies into property setters are not supported +> Injecting dependencies into property setters is not supported diff --git a/SECURITY.md b/SECURITY.md index a3e4f25..15fa2fa 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,9 +2,9 @@ ## Supported Versions -| Version | Supported | PHP Version | -|---------|--------------------|---------------------------------------------------------------------------------------------------------------------------| -| 1.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-dependency-injection/1.0.0) | +| Version | Supported | PHP Version | +|---------|--------------------|--------------------------------------------------------------------------------------------------------------------------| +| 1.x | :white_check_mark: | ![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-dependency-injection/1.3.0) | ## Reporting Potential Security Issues diff --git a/composer.json b/composer.json index 9e15116..0aa14e9 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "service" ], "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/orm": "^2.9 || ^3.0", "psr/container": "^1.0 || ^2.0" }, @@ -47,7 +47,8 @@ "scripts": { "check": [ "@cs-check", - "@test" + "@test", + "@static-analysis" ], "cs-check": "phpcs", "cs-fix": "phpcbf", diff --git a/docs/book/v1/configuration.md b/docs/book/v1/configuration.md index 1109acf..d4915b1 100644 --- a/docs/book/v1/configuration.md +++ b/docs/book/v1/configuration.md @@ -1,7 +1,6 @@ # Configuration -After installation, register `dot-dependency-injection` in your project by adding the below line to your configuration -aggregator (usually: `config/config.php`): +After installation, register `dot-dependency-injection` in your project by adding the below line to your configuration aggregator (usually: `config/config.php`): ```php Dot\DependencyInjection\ConfigProvider::class, diff --git a/docs/book/v1/factories.md b/docs/book/v1/factories.md index 1ffb8dd..a4bac6f 100644 --- a/docs/book/v1/factories.md +++ b/docs/book/v1/factories.md @@ -1,7 +1,6 @@ # Factories -`dot-dependency-injection` is based on 2 reusable factories - `AttributedRepositoryFactory` -and `AttributedServiceFactory` - able to inject any dependency into a class. +`dot-dependency-injection` is based on two reusable factories - `AttributedRepositoryFactory` and `AttributedServiceFactory` - able to inject any dependency into a class. ## AttributedRepositoryFactory @@ -12,25 +11,20 @@ Injects entity repositories into a class. - `Dot\DependencyInjection\Exception\RuntimeException` if repository does not exist - `Dot\DependencyInjection\Exception\RuntimeException` if repository does not extend `Doctrine\ORM\EntityRepository` - `Dot\DependencyInjection\Exception\RuntimeException` if repository does not have `#[Entity]` attribute -- `Psr\Container\NotFoundExceptionInterface` if `Doctrine\ORM\EntityManagerInterface` does not exist in the service - container -- `Psr\Container\ContainerExceptionInterface` if service manager is unable to provide an instance - of `Doctrine\ORM\EntityManagerInterface` +- `Psr\Container\NotFoundExceptionInterface` if `Doctrine\ORM\EntityManagerInterface` does not exist in the service container +- `Psr\Container\ContainerExceptionInterface` if service manager is unable to provide an instance of `Doctrine\ORM\EntityManagerInterface` ## AttributedServiceFactory 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. +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. ### Exceptions thrown - `Dot\DependencyInjection\Exception\RuntimeException` if service does not exist -- `Dot\DependencyInjection\Exception\RuntimeException` if service does not have `#[Inject]` attribute on it's - constructor +- `Dot\DependencyInjection\Exception\RuntimeException` if service does not have `#[Inject]` attribute on it's constructor - `Dot\DependencyInjection\Exception\RuntimeException` if service tries to inject itself recursively - `Psr\Container\NotFoundExceptionInterface` if a dependency does not exist in the service container - `Psr\Container\ContainerExceptionInterface` if service manager is unable to provide an instance of a dependency diff --git a/docs/book/v1/factories/repository.md b/docs/book/v1/factories/repository.md index 75f19a6..e8687a1 100644 --- a/docs/book/v1/factories/repository.md +++ b/docs/book/v1/factories/repository.md @@ -11,7 +11,7 @@ declare(strict_types=1); namespace YourApp\Repository; -#[Dot\DependencyInjection\Attribute\Entity(name: YourApp\Entity\Example::class)] +#[\Dot\DependencyInjection\Attribute\Entity(name: YourApp\Entity\Example::class)] class ExampleRepository extends Doctrine\ORM\EntityRepository { } @@ -25,7 +25,7 @@ Open the ConfigProvider of the module where your repository resides. Add a new entry under `factories`, where the key is your repository FQCN and the value is `Dot\DependencyInjection\Factory\AttributedRepositoryFactory::class`. -See below example for a better understanding of the file structure. +See the below example for a better understanding of the file structure. ```php