Skip to content

Commit

Permalink
Require Symfony 6.4+
Browse files Browse the repository at this point in the history
Add support for Symfony 7
Switch to somnambulist/enumeration package
Update redoc to 2.1.3
  • Loading branch information
dave-redfern committed Mar 2, 2024
1 parent a6eb5dc commit 90baa78
Show file tree
Hide file tree
Showing 60 changed files with 140 additions and 158 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ on:
jobs:
testsuite:
name: Unittests
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2']
php-version: ['8.1', '8.2', '8.3']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 1

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ Temporary Items
.apdisk
/.phpunit.result.cache
phpunit.xml
/.phpunit.cache
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Change Log
==========

2024-02-24 - 6.0.0
------------------

* Raise minimum Symfony to 6.4
* Add support for Symfony 7
* Update redoc version to 2.1.3
* Replace eloquent/enumeration with somnambulist/enumeration

2023-07-07
----------

* Raise minimum Symfony version to 6.2
* Remove deprecated interfaces
* Update tests to remove deprecated method calls

2023-01-29 - 5.2.3
------------------

Expand Down
28 changes: 14 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@
"psr/log": "^1|^2|^3",
"somnambulist/form-request-bundle": "^2.0",
"somnambulist/fractal-bundle": "^2.0",
"symfony/framework-bundle": "^6.1"
"symfony/framework-bundle": "^6.4|^7.0"
},
"require-dev": {
"phpunit/phpunit": "~9.5",
"doctrine/collections": "~1.6",
"pagerfanta/pagerfanta": "^3.5",
"monolog/monolog": "^3.2",
"phpunit/phpunit": "^10.5",
"doctrine/collections": "~1.8",
"pagerfanta/pagerfanta": "^3.8",
"monolog/monolog": "^3.4",
"somnambulist/api-client": "^4.0.0",
"somnambulist/domain": "^5.0.0",
"somnambulist/domain": "^6.0.0",
"somnambulist/read-models": "^4.0",
"symfony/browser-kit": "^6.0",
"symfony/phpunit-bridge": "^6.0",
"symfony/messenger": "^6.0",
"symfony/browser-kit": "^6.4",
"symfony/phpunit-bridge": "^6.4",
"symfony/messenger": "^6.4",
"symfony/monolog-bundle": "~3.5",
"symfony/serializer": "^6.0",
"symfony/stopwatch": "^6.0",
"symfony/twig-bundle": "^6.0",
"symfony/var-dumper": "^6.0",
"symfony/yaml": "^6.0"
"symfony/serializer": "^6.4",
"symfony/stopwatch": "^6.4",
"symfony/twig-bundle": "^6.4",
"symfony/var-dumper": "^6.4",
"symfony/yaml": "^6.4"
},
"autoload": {
"psr-4": {
Expand Down
29 changes: 13 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
backupGlobals="false" colors="true" bootstrap="vendor/autoload.php">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory>bin</directory>
<directory>tests</directory>
</exclude>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" colors="true"
bootstrap="vendor/autoload.php" cacheDirectory=".phpunit.cache">
<coverage/>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="memory_limit" value="256M"/>
<server name="APP_ENV" value="test" force="true"/>
<server name="KERNEL_CLASS" value="Somnambulist\Bundles\ApiBundle\Tests\Support\Kernel"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
<exclude>
<directory>bin</directory>
<directory>tests</directory>
</exclude>
</source>
</phpunit>
24 changes: 10 additions & 14 deletions src/ArgumentResolvers/ExternalIdentityValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@

use Somnambulist\Components\Models\Types\Identity\ExternalIdentity;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;

class ExternalIdentityValueResolver implements ArgumentValueResolverInterface
class ExternalIdentityValueResolver implements ValueResolverInterface
{
public function supports(Request $request, ArgumentMetadata $argument): bool
{
return
null !== $request->get('provider')
&&
null !== $request->get('identity')
&&
ExternalIdentity::class === $argument->getType()
;
}

public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
yield new ExternalIdentity($request->get('provider'), $request->get('identity'));
if ($argument->isVariadic()
|| !is_string($provider = $request->get('provider'))
|| !is_string($identity = $request->get('identity'))
) {
return [];
}

yield new ExternalIdentity($provider, $identity);
}
}
23 changes: 12 additions & 11 deletions src/ArgumentResolvers/UuidValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@

use Somnambulist\Components\Models\Types\Identity\AbstractIdentity;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
use function is_string;
use function is_subclass_of;

use function is_a;

class UuidValueResolver implements ArgumentValueResolverInterface
class UuidValueResolver implements ValueResolverInterface
{
public function supports(Request $request, ArgumentMetadata $argument): bool
{
return is_a($argument->getType(), AbstractIdentity::class, true);
}

public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
$class = $argument->getType();
if ($argument->isVariadic()
|| !is_string($value = $request->attributes->get($argument->getName()))
|| null === ($class = $argument->getType())
|| !is_subclass_of($argument->getType(), AbstractIdentity::class, true)
) {
return [];
}

yield new $class($request->get($argument->getName()));
yield new $class($value);
}
}
6 changes: 3 additions & 3 deletions src/Controllers/ApiDocController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
class ApiDocController extends AbstractController
{
public function __construct(
private OpenApiGenerator $generator,
private CacheItemPoolInterface $cache,
private int $cacheTime = 43200
private readonly OpenApiGenerator $generator,
private readonly CacheItemPoolInterface $cache,
private readonly int $cacheTime = 43200
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/SomnambulistApiExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class SomnambulistApiExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
Expand Down
1 change: 0 additions & 1 deletion src/Request/Behaviours/GetFieldsFromParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Somnambulist\Bundles\ApiBundle\Request\Behaviours;

use Symfony\Component\HttpFoundation\ParameterBag;

use function array_filter;

trait GetFieldsFromParameterBag
Expand Down
1 change: 0 additions & 1 deletion src/Request/Behaviours/GetFieldsFromValidatedData.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Somnambulist\Bundles\ApiBundle\Request\Behaviours;

use Somnambulist\Bundles\FormRequestBundle\Http\ValidatedDataBag;

use function array_filter;

/**
Expand Down
1 change: 0 additions & 1 deletion src/Request/Behaviours/GetFiltersFromParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Somnambulist\Bundles\ApiBundle\Request\Behaviours;

use Symfony\Component\HttpFoundation\ParameterBag;

use function array_filter;

trait GetFiltersFromParameterBag
Expand Down
1 change: 0 additions & 1 deletion src/Request/Behaviours/GetIncludesFromParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Somnambulist\Bundles\ApiBundle\Request\Behaviours;

use Symfony\Component\HttpFoundation\ParameterBag;

use function array_filter;
use function explode;

Expand Down
1 change: 0 additions & 1 deletion src/Request/Behaviours/GetIncludesFromValidatedData.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Somnambulist\Bundles\ApiBundle\Request\Behaviours;

use Somnambulist\Bundles\FormRequestBundle\Http\ValidatedDataBag;

use function array_filter;
use function explode;

Expand Down
1 change: 0 additions & 1 deletion src/Request/Behaviours/GetNullOrValueFromParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Somnambulist\Bundles\ApiBundle\Request\Behaviours;

use Symfony\Component\HttpFoundation\ParameterBag;

use function array_combine;
use function array_map;
use function array_reduce;
Expand Down
1 change: 0 additions & 1 deletion src/Request/Behaviours/GetOrderByFromParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Somnambulist\Bundles\ApiBundle\Request\Filters\ConvertOrderByToArray;
use Symfony\Component\HttpFoundation\ParameterBag;

use function is_null;

trait GetOrderByFromParameterBag
Expand Down
3 changes: 1 addition & 2 deletions src/Request/Behaviours/GetPaginationFromParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Somnambulist\Bundles\ApiBundle\Request\Behaviours;

use Symfony\Component\HttpFoundation\ParameterBag;

use function max;
use function min;

Expand Down Expand Up @@ -40,7 +39,7 @@ protected function doGetOffset(ParameterBag $bag, int $limit = null): int
return $bag->getInt('offset') < 1 ? 0 : $bag->getInt('offset');
}

return (int)($this->doGetPage($bag) - 1) * $this->ensureValueIsInteger($limit, $this->limit);
return ($this->doGetPage($bag) - 1) * $this->ensureValueIsInteger($limit, $this->limit);
}

protected function doGetOffsetMarker(ParameterBag $bag): ?string
Expand Down
6 changes: 2 additions & 4 deletions src/Request/Filters/ApplyApiExpressionsToDBALQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use InvalidArgumentException;
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\CompositeExpression as APIExpression;
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\Expression;

use function array_keys;
use function array_map;
use function str_replace;
Expand Down Expand Up @@ -115,8 +114,7 @@ private function mapOperatorToMethod(string $field, string $operator): string
'NOT LIKE' => 'notLike',
'IS NULL' => 'isNull',
'IS NOT NULL' => 'isNotNull',
'ILIKE' => 'comparison',
'NOT ILIKE' => 'comparison',
'ILIKE', 'NOT ILIKE' => 'comparison',
};
}

Expand All @@ -143,7 +141,7 @@ private function mapValuesToPlaceholders(Expression $part): array
return [];
}

return [$this->makePlaceholder($field, 0) => $part->value];
return [$this->makePlaceholder($field) => $part->value];
}

private function mapArrayValues(string $field, array $values): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Somnambulist\Bundles\ApiBundle\Request\Filters\Decoders\Behaviours;

use function explode;
use function str_contains;
use function str_getcsv;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\CompositeExpression;
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\Expression;
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\ExpressionInterface;

use function explode;
use function is_numeric;
use function str_contains;
Expand Down
1 change: 0 additions & 1 deletion src/Request/Filters/Decoders/NestedArrayFilterDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\CompositeExpression;
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\Expression;
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\ExpressionInterface;

use function array_key_exists;

/**
Expand Down
1 change: 0 additions & 1 deletion src/Request/Filters/Decoders/OpenStackApiFilterDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Somnambulist\Bundles\ApiBundle\Request\Filters\Decoders\Behaviours\ConvertStringToArray;
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\CompositeExpression;
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\Expression;

use function explode;
use function in_array;
use function str_contains;
Expand Down
1 change: 0 additions & 1 deletion src/Request/Filters/Decoders/SimpleApiFilterDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Somnambulist\Bundles\ApiBundle\Request\Filters\Decoders\Behaviours\ConvertStringToArray;
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\CompositeExpression;
use Somnambulist\Bundles\ApiBundle\Request\Filters\Expression\Expression;

use function in_array;
use function is_scalar;

Expand Down
1 change: 0 additions & 1 deletion src/Request/Filters/Expression/CompositeExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Countable;
use IteratorAggregate;
use Traversable;

use function array_key_exists;
use function count;

Expand Down
7 changes: 0 additions & 7 deletions src/Request/SearchFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@

use Somnambulist\Bundles\ApiBundle\Request\Behaviours\GetFieldsFromValidatedData;
use Somnambulist\Bundles\ApiBundle\Request\Behaviours\GetIncludesFromValidatedData;
use Somnambulist\Bundles\ApiBundle\Request\Contracts\HasFields;
use Somnambulist\Bundles\ApiBundle\Request\Contracts\HasFilters;
use Somnambulist\Bundles\ApiBundle\Request\Contracts\HasIncludes;
use Somnambulist\Bundles\ApiBundle\Request\Contracts\HasMarker;
use Somnambulist\Bundles\ApiBundle\Request\Contracts\HasOffsetLimit;
use Somnambulist\Bundles\ApiBundle\Request\Contracts\HasPagination;
use Somnambulist\Bundles\ApiBundle\Request\Contracts\Searchable;
use Somnambulist\Bundles\ApiBundle\Request\Filters\ConvertOrderByToArray;
use Somnambulist\Bundles\FormRequestBundle\Http\FormRequest as BaseFormRequest;

use function array_filter;
use function is_null;
use function max;
Expand Down
Loading

0 comments on commit 90baa78

Please sign in to comment.