Skip to content

Commit

Permalink
Merge pull request #93 from chives/dev
Browse files Browse the repository at this point in the history
Fully unlock Symfony 6.x and doctrine/orm ^3.0
  • Loading branch information
rn0 authored Jun 20, 2024
2 parents 3453929 + ffe36aa commit 208ac27
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 3 additions & 8 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
31 changes: 15 additions & 16 deletions Doctrine/ResourceRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -66,48 +66,47 @@ 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');
}

/**
* Unsupported method
*
* @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()
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 208ac27

Please sign in to comment.