diff --git a/src/HttpCache/State/AddHeadersProcessor.php b/src/HttpCache/State/AddHeadersProcessor.php index eb856313efd..e1c008b7618 100644 --- a/src/HttpCache/State/AddHeadersProcessor.php +++ b/src/HttpCache/State/AddHeadersProcessor.php @@ -18,10 +18,16 @@ use ApiPlatform\State\ProcessorInterface; use Symfony\Component\HttpFoundation\Response; +/** + * @template T1 + * @template T2 + * + * @implements ProcessorInterface + */ final class AddHeadersProcessor implements ProcessorInterface { /** - * @param ProcessorInterface|ProcessorInterface $decorated + * @param ProcessorInterface $decorated */ public function __construct(private readonly ProcessorInterface $decorated, private readonly bool $etag = false, private readonly ?int $maxAge = null, private readonly ?int $sharedMaxAge = null, private readonly ?array $vary = null, private readonly ?bool $public = null, private readonly ?int $staleWhileRevalidate = null, private readonly ?int $staleIfError = null) { diff --git a/src/Hydra/State/HydraLinkProcessor.php b/src/Hydra/State/HydraLinkProcessor.php index 0adff87a970..3faff4f7aaf 100644 --- a/src/Hydra/State/HydraLinkProcessor.php +++ b/src/Hydra/State/HydraLinkProcessor.php @@ -22,12 +22,18 @@ use Symfony\Component\WebLink\GenericLinkProvider; use Symfony\Component\WebLink\Link; +/** + * @template T1 + * @template T2 + * + * @implements ProcessorInterface + */ final class HydraLinkProcessor implements ProcessorInterface { use CorsTrait; /** - * @param ProcessorInterface $decorated + * @param ProcessorInterface $decorated */ public function __construct(private readonly ProcessorInterface $decorated, private readonly UrlGeneratorInterface $urlGenerator) { diff --git a/src/State/CallableProcessor.php b/src/State/CallableProcessor.php index 4aace698ac3..e913283ca2a 100644 --- a/src/State/CallableProcessor.php +++ b/src/State/CallableProcessor.php @@ -17,6 +17,12 @@ use ApiPlatform\Metadata\Operation; use Psr\Container\ContainerInterface; +/** + * @template T1 + * @template T2 + * + * @implements ProcessorInterface + */ final class CallableProcessor implements ProcessorInterface { public function __construct(private readonly ?ContainerInterface $locator = null) @@ -40,7 +46,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables = throw new RuntimeException(sprintf('Processor "%s" not found on operation "%s"', $processor, $operation->getName())); } - /** @var ProcessorInterface $processorInstance */ + /** @var ProcessorInterface $processorInstance */ $processorInstance = $this->locator->get($processor); return $processorInstance->process($data, $operation, $uriVariables, $context); diff --git a/src/State/Processor/AddLinkHeaderProcessor.php b/src/State/Processor/AddLinkHeaderProcessor.php index de738486d63..2f58e922351 100644 --- a/src/State/Processor/AddLinkHeaderProcessor.php +++ b/src/State/Processor/AddLinkHeaderProcessor.php @@ -18,8 +18,17 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\WebLink\HttpHeaderSerializer; +/** + * @template T1 + * @template T2 + * + * @implements ProcessorInterface + */ final class AddLinkHeaderProcessor implements ProcessorInterface { + /** + * @param ProcessorInterface $decorated + */ public function __construct(private readonly ProcessorInterface $decorated, private readonly ?HttpHeaderSerializer $serializer = new HttpHeaderSerializer()) { } diff --git a/src/State/Processor/RespondProcessor.php b/src/State/Processor/RespondProcessor.php index b58f97239c0..df451d0ceb0 100644 --- a/src/State/Processor/RespondProcessor.php +++ b/src/State/Processor/RespondProcessor.php @@ -24,6 +24,7 @@ use ApiPlatform\Metadata\Util\ClassInfoTrait; use ApiPlatform\Metadata\Util\CloneTrait; use ApiPlatform\State\ProcessorInterface; +use DateTimeInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface as SymfonyHttpExceptionInterface; @@ -74,7 +75,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables = $status = $operation->getStatus(); if ($sunset = $operation->getSunset()) { - $headers['Sunset'] = (new \DateTimeImmutable($sunset))->format(\DateTime::RFC1123); + $headers['Sunset'] = (new \DateTimeImmutable($sunset))->format(DateTimeInterface::RFC1123); } if ($acceptPatch = $operation->getAcceptPatch()) { diff --git a/src/State/Processor/SerializeProcessor.php b/src/State/Processor/SerializeProcessor.php index c01098ebe6b..a2cc9da24dd 100644 --- a/src/State/Processor/SerializeProcessor.php +++ b/src/State/Processor/SerializeProcessor.php @@ -26,10 +26,18 @@ /** * Serializes data. * + * @template T1 + * @template T2 + * + * @implements ProcessorInterface + * * @author Kévin Dunglas */ final class SerializeProcessor implements ProcessorInterface { + /** + * @param ProcessorInterface $processor + */ public function __construct(private readonly ProcessorInterface $processor, private readonly SerializerInterface $serializer, private readonly SerializerContextBuilderInterface $serializerContextBuilder) { } diff --git a/src/State/Processor/WriteProcessor.php b/src/State/Processor/WriteProcessor.php index eb611ac5ba3..b449d875c13 100644 --- a/src/State/Processor/WriteProcessor.php +++ b/src/State/Processor/WriteProcessor.php @@ -21,6 +21,11 @@ /** * Bridges persistence and the API system. * + * @template T1 + * @template T2 + * + * @implements ProcessorInterface + * * @author Kévin Dunglas * @author Baptiste Meyer */ @@ -28,6 +33,10 @@ final class WriteProcessor implements ProcessorInterface { use ClassInfoTrait; + /** + * @param ProcessorInterface $processor + * @param ProcessorInterface $callableProcessor + */ public function __construct(private readonly ProcessorInterface $processor, private readonly ProcessorInterface $callableProcessor) { } diff --git a/src/State/ProcessorInterface.php b/src/State/ProcessorInterface.php index 822774e90fe..b88f77f3716 100644 --- a/src/State/ProcessorInterface.php +++ b/src/State/ProcessorInterface.php @@ -19,8 +19,8 @@ /** * Processes data: sends an email, persists to storage, adds to queue etc. * - * @template T1 of object - * @template T2 of object + * @template T1 + * @template T2 * * @author Antoine Bluchet */ diff --git a/src/Symfony/State/MercureLinkProcessor.php b/src/Symfony/State/MercureLinkProcessor.php index 9f1d31eb94e..a71778a0e40 100644 --- a/src/Symfony/State/MercureLinkProcessor.php +++ b/src/Symfony/State/MercureLinkProcessor.php @@ -17,10 +17,16 @@ use ApiPlatform\State\ProcessorInterface; use Symfony\Component\Mercure\Discovery; +/** + * @template T1 + * @template T2 + * + * @implements ProcessorInterface + */ final class MercureLinkProcessor implements ProcessorInterface { /** - * @param ProcessorInterface $decorated + * @param ProcessorInterface $decorated */ public function __construct(private readonly ProcessorInterface $decorated, private readonly Discovery $discovery) { diff --git a/tests/State/RespondProcessorTest.php b/tests/State/RespondProcessorTest.php index 0550b6fee45..89ace0125fd 100644 --- a/tests/State/RespondProcessorTest.php +++ b/tests/State/RespondProcessorTest.php @@ -71,7 +71,7 @@ public function testRedirectToOperation(): void return ($args[2] ?? null)?->getUriTemplate() ?? '/default'; }); - /** @var ProcessorInterface $respondProcessor */ + /** @var ProcessorInterface $respondProcessor */ $respondProcessor = new RespondProcessor($iriConverter->reveal(), $resourceClassResolver->reveal(), $operationMetadataFactory->reveal()); $response = $respondProcessor->process('content', $canonicalUriTemplateRedirectingOperation, context: [ @@ -103,7 +103,7 @@ public function testAddsExceptionHeaders(): void { $operation = new Get(); - /** @var ProcessorInterface $respondProcessor */ + /** @var ProcessorInterface $respondProcessor */ $respondProcessor = new RespondProcessor(); $req = new Request(); $req->attributes->set('exception', new TooManyRequestsHttpException(32));