diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 693651f..1b9a51b 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -4,6 +4,7 @@ ->in(__DIR__) ->exclude('var') ->exclude('tmp') + ->exclude('Tests/Fixtures/Php81') // @todo remove this when we drop PHP 7.X support ; return (new PhpCsFixer\Config()) diff --git a/Attribute/Repository.php b/Attribute/Repository.php new file mode 100644 index 0000000..c70bd92 --- /dev/null +++ b/Attribute/Repository.php @@ -0,0 +1,32 @@ +assertEquals($e, WithEnumEntity::first()); } + public function testInjectRepositoryWithAttribute() + { + if (PHP_VERSION_ID < 80100 || !class_exists(AutowireInline::class)) { + $this->markTestSkipped(); + } + + $kernel = new TestKernel('dev', true); + $kernel->boot(); + + /** @var MyService $service */ + $service = $kernel->getContainer()->get(MyService::class); + + $this->assertInstanceOf(EntityRepository::class, $service->repository); + $this->assertSame(TestEntity::class, $service->repository->entityClass()); + } + private function getCommand(Application $console, string $name): Command { $command = $console->get($name); diff --git a/Tests/Fixtures/Php81/MyService.php b/Tests/Fixtures/Php81/MyService.php new file mode 100644 index 0000000..bcfe205 --- /dev/null +++ b/Tests/Fixtures/Php81/MyService.php @@ -0,0 +1,29 @@ += 80100 && class_exists(AutowireInline::class)) { + class MyService + { + /** + * @var EntityRepository + */ + #[Repository(TestEntity::class)] + public $repository; + + public function __construct( + #[Repository(TestEntity::class)] + EntityRepository $repository + ) { + $this->repository = $repository; + } + } +} else { + // Add class to avoid error in PHP 7.X + class MyService {} +} diff --git a/Tests/conf.yaml b/Tests/conf.yaml index 79a9b1d..f91d263 100644 --- a/Tests/conf.yaml +++ b/Tests/conf.yaml @@ -26,5 +26,10 @@ services: exclude: - './Fixtures/Php81/*Enum.php' + Bdf\PrimeBundle\Tests\Fixtures\Php81\MyService: + autowire: true + autoconfigure: true + public: true + Bdf\PrimeBundle\Tests\Fixtures\A: arguments: ['bar'] diff --git a/composer.json b/composer.json index 2dc3299..99d8e2e 100644 --- a/composer.json +++ b/composer.json @@ -45,7 +45,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.10-dev" } }, "suggest": {