Skip to content

Commit

Permalink
Merge pull request #39 from shopware/fix-symfony-resolver-interface
Browse files Browse the repository at this point in the history
fix: adds checks for argument resolving
  • Loading branch information
shyim committed Aug 28, 2023
2 parents e29a526 + bac03a6 commit 5a1d2c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 4 additions & 3 deletions src/ArgumentValueResolver/ContextArgumentResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ public function supports(Request $request, ArgumentMetadata $argument): bool
*/
public function resolve(Request $request, ArgumentMetadata $argument): iterable
{
/** @var class-string|null $type */
$type = $argument->getType();
if ($type === null) {
if(!$this->supports($request, $argument)) {
return;
}

Expand All @@ -81,6 +79,9 @@ public function resolve(Request $request, ArgumentMetadata $argument): iterable
$request->attributes->set(AppRequest::PSR_REQUEST_ATTRIBUTE, $psrRequest);
}

/** @var class-string $type */
$type = $argument->getType();

if ($type === RequestInterface::class) {
yield $psrRequest;
return;
Expand Down
7 changes: 2 additions & 5 deletions tests/ArgumentValueResolver/ContextArgumentResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public function testSigningActions(string $action, bool $requiresSigning): void
}
}

public function testNoMatchingTypeThrows(): void
public function testIgnoresUnknownArgumentTypes(): void
{
$request = $this->getRequest();

Expand All @@ -299,10 +299,7 @@ public function testNoMatchingTypeThrows(): void
$this->getPsrHttpFactory()
);

static::expectException(\RuntimeException::class);
static::expectExceptionMessage('Unsupported type stdClass');

\iterator_to_array($resolver->resolve($request, new ArgumentMetadata('test', \stdClass::class, false, false, null)));
static::assertEmpty(\iterator_to_array($resolver->resolve($request, new ArgumentMetadata('test', \stdClass::class, false, false, null))));
}

public function getRequest(): Request
Expand Down

0 comments on commit 5a1d2c7

Please sign in to comment.