Skip to content

Commit dbbb902

Browse files
PUR2-2381: Fixes for compatibility with symfony7, php8 (#17)
* PUR2-2381: Fixes for compatibility with symfony7, php8 * PUR2-2381: Fixes for compatibility with symfony7, php8 * PUR2-2381: Fixes for compatibility with symfony7, php8 * PUR2-2381: Fixes for compatibility with symfony7, php8 * PUR2-2381: Fixes for compatibility with symfony7, php8 * PUR2-2381: Fixes for compatibility with symfony7, php8
1 parent 515cd7b commit dbbb902

File tree

6 files changed

+26
-36
lines changed

6 files changed

+26
-36
lines changed

.github/workflows/symfony.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
operating-system: [ 'ubuntu-latest' ]
25-
php-versions: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
25+
php-versions: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
2626
phpunit-versions: [ 'latest' ]
2727
steps:
2828
- name: Setup PHP

ArgumentResolver/ServiceRequestResolver.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Auto1\ServiceAPIHandlerBundle\EventListener\ServiceResponseListener;
1717
use Auto1\ServiceAPIRequest\ServiceRequestInterface;
1818
use Symfony\Component\HttpFoundation\Request;
19-
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
19+
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
2020
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
2121
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
2222
use Symfony\Component\Serializer\Exception\ExceptionInterface;
@@ -26,7 +26,7 @@
2626
/**
2727
* Class ArgumentResolver
2828
*/
29-
class ServiceRequestResolver implements ArgumentValueResolverInterface
29+
class ServiceRequestResolver implements ValueResolverInterface
3030
{
3131
use LoggerAwareTrait;
3232
/**
@@ -61,19 +61,15 @@ public function __construct(
6161
$this->serviceResponseListener = $serviceResponseListener;
6262
}
6363

64-
/**
65-
* {@inheritdoc}
66-
*/
67-
public function supports(Request $request, ArgumentMetadata $argument): bool
68-
{
69-
return is_subclass_of($argument->getType(), ServiceRequestInterface::class, true);
70-
}
71-
7264
/**
7365
* {@inheritdoc}
7466
*/
7567
public function resolve(Request $request, ArgumentMetadata $argument): iterable
7668
{
69+
if (!$this->supports($argument)) {
70+
return [];
71+
}
72+
7773
$endpoint = $this->endpointRegistry->getEndpoint(
7874
(new \ReflectionClass($argument->getType()))->newInstanceWithoutConstructor()
7975
);
@@ -115,4 +111,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
115111
throw new BadRequestHttpException('Request deserialization error');
116112
}
117113
}
114+
115+
private function supports(ArgumentMetadata $argument): bool
116+
{
117+
return is_subclass_of($argument->getType(), ServiceRequestInterface::class, true);
118+
}
118119
}

EventListener/ServiceResponseListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(SerializerInterface $serializer)
4848
/**
4949
* {@inheritdoc}
5050
*/
51-
public static function getSubscribedEvents()
51+
public static function getSubscribedEvents(): array
5252
{
5353
return [
5454
KernelEvents::VIEW => 'onKernelView',

Routing/EndpointLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(EndpointRegistryInterface $endpointRegistry, array $
4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function load($resource, $type = null)
46+
public function load($resource, $type = null): object
4747
{
4848
$routes = new RouteCollection();
4949

@@ -73,7 +73,7 @@ public function load($resource, $type = null)
7373
/**
7474
* {@inheritdoc}
7575
*/
76-
public function supports($resource, $type = null)
76+
public function supports($resource, $type = null): bool
7777
{
7878
return 'endpoint_handler' === $type;
7979
}

Tests/ArgumentResolver/ServiceRequestResolverTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,6 @@ public function testResolve(): void
180180
$this->assertInstanceOf(RequestStub::class, $generator->current());
181181
}
182182

183-
/**
184-
* @dataProvider getDataForTestSupports
185-
* @param ArgumentMetadata $argumentMetadata
186-
* @param bool $expectedResult
187-
* @return void
188-
*/
189-
public function testSupports(ArgumentMetadata $argumentMetadata, bool $expectedResult): void
190-
{
191-
$this->assertSame($expectedResult, $this->serviceRequestResolver->supports(new Request(), $argumentMetadata));
192-
}
193-
194183
public static function getDataForTestSupports(): \Generator
195184
{
196185
yield 'supported' => [self::createMetadata(), true];

composer.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^7.4|^8.0",
13+
"php": "^8.1",
1414
"auto1-oss/service-api-request": "^1.0",
1515
"auto1-oss/service-api-components-bundle": "^1.0",
16-
"symfony/serializer" : "~5.0|~6.0|~7.0",
17-
"symfony/monolog-bridge": "~5.0|~6.0|~7.0",
18-
"symfony/dependency-injection": "~5.0|~6.0|~7.0",
19-
"symfony/config": "~5.0|~6.0|~7.0",
20-
"symfony/http-kernel": "~5.0|~6.0|~7.0",
21-
"symfony/http-foundation": "~5.0|~6.0|~7.0",
22-
"symfony/property-info": "~5.0|~6.0|~7.0",
23-
"symfony/yaml": "~5.0|~6.0|~7.0",
16+
"symfony/serializer" : "~6.4|~7.0",
17+
"symfony/monolog-bridge": "~6.4|~7.0",
18+
"symfony/dependency-injection": "~6.4|~7.0",
19+
"symfony/config": "~6.4|~7.0",
20+
"symfony/http-kernel": "~6.4|~7.0",
21+
"symfony/http-foundation": "~6.4|~7.0",
22+
"symfony/property-info": "~6.4|~7.0",
23+
"symfony/yaml": "~6.4|~7.0",
2424
"monolog/monolog": "~1.22|^2.9|^3.0",
25-
"symfony/routing": "~5.0|~6.0|~7.0"
25+
"symfony/routing": "~6.4|~7.0"
2626
},
2727
"require-dev": {
28-
"symfony/console": "~5.0|~6.0|~7.0",
28+
"symfony/console": "~6.4|~7.0",
2929
"phpunit/phpunit": "^7.5|^8.0|^9.6",
3030
"phpspec/prophecy": "^1.7.2"
3131
},

0 commit comments

Comments
 (0)