diff --git a/.travis.yml b/.travis.yml index 8ca6cae..5516a62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,11 @@ matrix: - php: 7.4 env: - COMPOSER_FLAGS='--prefer-lowest' + - php: 7.4 - php: 8.0 - php: 8.1 - php: 8.2 + - php: 8.3 cache: directories: diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 037f644..90525f6 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -18,15 +18,10 @@ class Configuration implements ConfigurationInterface { private const SUPPORTED_DRIVERS = ['orm']; - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { - if (true === method_exists(TreeBuilder::class, 'getRootNode')) { - $treeBuilder = new TreeBuilder('fsi_resource_repository'); - $rootNode = $treeBuilder->getRootNode(); - } else { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('fsi_resource_repository'); - } + $treeBuilder = new TreeBuilder('fsi_resource_repository'); + $rootNode = $treeBuilder->getRootNode(); $rootNode->children() ->scalarNode('db_driver') diff --git a/Doctrine/ResourceRepository.php b/Doctrine/ResourceRepository.php index 5d13148..ef6a445 100644 --- a/Doctrine/ResourceRepository.php +++ b/Doctrine/ResourceRepository.php @@ -23,7 +23,7 @@ class ResourceRepository extends EntityRepository implements ResourceValueReposi * @param null $lockVersion * @return ResourceValue */ - public function find($id, $lockMode = null, $lockVersion = null) + public function find($id, $lockMode = null, $lockVersion = null): ResourceValue { if ($lockMode === null) { $lockMode = LockMode::NONE; @@ -66,26 +66,26 @@ public function remove(ResourceValue $resourceValue): void * Unsupported method * * @param array $criteria - * @param array $orderBy - * @param null $limit - * @param null $offset - * @return array|void + * @param array|null $orderBy + * @param int|null $limit + * @param int|null $offset + * @return array * @throws EntityRepositoryException */ - public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array { - $this->throwBadMethodException('findBy'); + throw $this->throwBadMethodException('findBy'); } /** * Unsupported method * - * @return array|void + * @return array * @throws EntityRepositoryException */ - public function findAll() + public function findAll(): array { - $this->throwBadMethodException('findAll'); + throw $this->throwBadMethodException('findAll'); } /** @@ -93,21 +93,20 @@ public function findAll() * * @param array $criteria * @param array $orderBy - * @return object|void + * @return ResourceValue|null * @throws EntityRepositoryException */ - public function findOneBy(array $criteria, array $orderBy = null) + public function findOneBy(array $criteria, array $orderBy = null): ?ResourceValue { - $this->throwBadMethodException('findOneBy'); + throw $this->throwBadMethodException('findOneBy'); } /** * @param string $method - * @throws EntityRepositoryException */ - private function throwBadMethodException(string $method): void + private function throwBadMethodException(string $method): EntityRepositoryException { - throw new EntityRepositoryException(sprintf( + return new EntityRepositoryException(sprintf( 'Method "%s" is not supported in "%s" entity repository', $method, $this->getEntityName() diff --git a/composer.json b/composer.json index 295371a..99253d7 100644 --- a/composer.json +++ b/composer.json @@ -32,10 +32,10 @@ "twig/twig": "^3.7" }, "require-dev": { - "doctrine/orm": "^2.5", + "doctrine/orm": "^2.5|^3.0", "friendsofsymfony/ckeditor-bundle": "^2.1", - "fsi/files": "^2.0.4", - "fsi/form-extensions-bundle": "^2.2", + "fsi/files": "^2.0.4@dev", + "fsi/form-extensions-bundle": "^2.2@dev", "phpunit/phpunit": "^9.5|^10.0", "phpspec/phpspec": "^7.4", "phpstan/phpstan": "^1.10", diff --git a/spec/FSi/Bundle/ResourceRepositoryBundle/Repository/RepositorySpec.php b/spec/FSi/Bundle/ResourceRepositoryBundle/Repository/RepositorySpec.php index bd91acd..4d885a0 100644 --- a/spec/FSi/Bundle/ResourceRepositoryBundle/Repository/RepositorySpec.php +++ b/spec/FSi/Bundle/ResourceRepositoryBundle/Repository/RepositorySpec.php @@ -11,7 +11,10 @@ namespace spec\FSi\Bundle\ResourceRepositoryBundle\Repository; +use Doctrine\ORM\EntityRepository; +use Doctrine\Persistence\ObjectRepository; use FSi\Bundle\ResourceRepositoryBundle\Doctrine\ResourceRepository; +use FSi\Bundle\ResourceRepositoryBundle\Model\ResourceValueRepository; use FSi\Bundle\ResourceRepositoryBundle\Repository\MapBuilder; use FSi\Bundle\ResourceRepositoryBundle\Repository\Repository; use FSi\Bundle\ResourceRepositoryBundle\Repository\Resource\Type\TextType; @@ -21,7 +24,7 @@ class RepositorySpec extends ObjectBehavior { - public function let(MapBuilder $builder, ResourceRepository $repository): void + public function let(MapBuilder $builder, ResourceValueRepository $repository): void { $this->beConstructedWith($builder, $repository, Resource::class); } @@ -39,7 +42,7 @@ public function it_return_null_if_resource_entity_does_not_exist(MapBuilder $bui public function it_return_null_if_entity_field_is_null( MapBuilder $builder, - ResourceRepository $repository, + ResourceValueRepository $repository, TextType $resource, Resource $entity ): void { @@ -54,7 +57,7 @@ public function it_return_null_if_entity_field_is_null( public function it_return_null_if_entity_field_is_empty_string( MapBuilder $builder, - ResourceRepository $repository, + ResourceValueRepository $repository, TextType $resource, Resource $entity ): void { @@ -69,7 +72,7 @@ public function it_return_null_if_entity_field_is_empty_string( public function it_return_0_if_entity_field_is_zero( MapBuilder $builder, - ResourceRepository $repository, + ResourceValueRepository $repository, TextType $resource, Resource $entity ): void { @@ -84,7 +87,7 @@ public function it_return_0_if_entity_field_is_zero( public function it_sets_entity_field_on_existing_value( MapBuilder $builder, - ResourceRepository $repository, + ResourceValueRepository $repository, TextType $resource, Resource $entity ): void { @@ -99,7 +102,7 @@ public function it_sets_entity_field_on_existing_value( public function it_removes_entity_when_setting_empty_value( MapBuilder $builder, - ResourceRepository $repository, + ResourceValueRepository $repository, TextType $resource, Resource $entity ): void {