mirror of
https://github.com/symfony/http-kernel.git
synced 2026-03-24 01:12:09 +01:00
[Components] Convert to native return types
This commit is contained in:
committed by
Nicolas Grekas
parent
d61a8ffb4a
commit
34cbd3eea1
@@ -34,27 +34,19 @@ abstract class Bundle implements BundleInterface
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function shutdown()
|
||||
public function shutdown(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method can be overridden to register compilation passes,
|
||||
* other extensions, ...
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build(ContainerBuilder $container)
|
||||
public function build(ContainerBuilder $container): void
|
||||
{
|
||||
}
|
||||
|
||||
@@ -121,10 +113,7 @@ abstract class Bundle implements BundleInterface
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function registerCommands(Application $application)
|
||||
public function registerCommands(Application $application): void
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +67,5 @@ interface BundleInterface
|
||||
*/
|
||||
public function getPath(): string;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setContainer(?ContainerInterface $container);
|
||||
public function setContainer(?ContainerInterface $container): void;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ interface CacheClearerInterface
|
||||
{
|
||||
/**
|
||||
* Clears any caches necessary.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear(string $cacheDir);
|
||||
public function clear(string $cacheDir): void;
|
||||
}
|
||||
|
||||
@@ -57,10 +57,7 @@ class Psr6CacheClearer implements CacheClearerInterface
|
||||
return $this->pools[$name]->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function clear(string $cacheDir)
|
||||
public function clear(string $cacheDir): void
|
||||
{
|
||||
foreach ($this->pools as $pool) {
|
||||
$pool->clear();
|
||||
|
||||
@@ -18,10 +18,7 @@ namespace Symfony\Component\HttpKernel\CacheWarmer;
|
||||
*/
|
||||
abstract class CacheWarmer implements CacheWarmerInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function writeCacheFile(string $file, $content)
|
||||
protected function writeCacheFile(string $file, $content): void
|
||||
{
|
||||
$tmpFile = @tempnam(\dirname($file), basename($file));
|
||||
if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) {
|
||||
|
||||
@@ -25,8 +25,6 @@ interface CacheWarmerInterface extends WarmableInterface
|
||||
*
|
||||
* A warmer should return true if the cache can be
|
||||
* generated incrementally and on-demand.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isOptional();
|
||||
public function isOptional(): bool;
|
||||
}
|
||||
|
||||
@@ -23,5 +23,5 @@ interface WarmableInterface
|
||||
*
|
||||
* @return string[] A list of classes or files to preload on PHP 7.4+
|
||||
*/
|
||||
public function warmUp(string $cacheDir);
|
||||
public function warmUp(string $cacheDir): array;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ abstract class DataCollector implements DataCollectorInterface
|
||||
/**
|
||||
* @return callable[] The casters to add to the cloner
|
||||
*/
|
||||
protected function getCasters()
|
||||
protected function getCasters(): array
|
||||
{
|
||||
$casters = [
|
||||
'*' => function ($v, array $a, Stub $s, $isNested) {
|
||||
@@ -82,10 +82,7 @@ abstract class DataCollector implements DataCollectorInterface
|
||||
return ['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup()
|
||||
public function __wakeup(): void
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -24,15 +24,11 @@ interface DataCollectorInterface extends ResetInterface
|
||||
{
|
||||
/**
|
||||
* Collects data for the given Request and Response.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null);
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null): void;
|
||||
|
||||
/**
|
||||
* Returns the name of the collector.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName();
|
||||
public function getName(): string;
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ interface LateDataCollectorInterface
|
||||
{
|
||||
/**
|
||||
* Collects data as late as possible.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function lateCollect();
|
||||
public function lateCollect(): void;
|
||||
}
|
||||
|
||||
@@ -195,74 +195,47 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
return $this->data['path_info'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getRequestRequest()
|
||||
public function getRequestRequest(): ParameterBag
|
||||
{
|
||||
return new ParameterBag($this->data['request_request']->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getRequestQuery()
|
||||
public function getRequestQuery(): ParameterBag
|
||||
{
|
||||
return new ParameterBag($this->data['request_query']->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getRequestFiles()
|
||||
public function getRequestFiles(): ParameterBag
|
||||
{
|
||||
return new ParameterBag($this->data['request_files']->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getRequestHeaders()
|
||||
public function getRequestHeaders(): ParameterBag
|
||||
{
|
||||
return new ParameterBag($this->data['request_headers']->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getRequestServer(bool $raw = false)
|
||||
public function getRequestServer(bool $raw = false): ParameterBag
|
||||
{
|
||||
return new ParameterBag($this->data['request_server']->getValue($raw));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getRequestCookies(bool $raw = false)
|
||||
public function getRequestCookies(bool $raw = false): ParameterBag
|
||||
{
|
||||
return new ParameterBag($this->data['request_cookies']->getValue($raw));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getRequestAttributes()
|
||||
public function getRequestAttributes(): ParameterBag
|
||||
{
|
||||
return new ParameterBag($this->data['request_attributes']->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getResponseHeaders()
|
||||
public function getResponseHeaders(): ParameterBag
|
||||
{
|
||||
return new ParameterBag($this->data['response_headers']->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getResponseCookies()
|
||||
public function getResponseCookies(): ParameterBag
|
||||
{
|
||||
return new ParameterBag($this->data['response_cookies']->getValue());
|
||||
}
|
||||
@@ -300,18 +273,12 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
return $this->data['content'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isJsonRequest()
|
||||
public function isJsonRequest(): bool
|
||||
{
|
||||
return 1 === preg_match('{^application/(?:\w+\++)*json$}i', $this->data['request_headers']['content-type']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPrettyJson()
|
||||
public function getPrettyJson(): ?string
|
||||
{
|
||||
$decoded = json_decode($this->getContent());
|
||||
|
||||
@@ -343,10 +310,7 @@ class RequestDataCollector extends DataCollector implements EventSubscriberInter
|
||||
return $this->data['locale'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ParameterBag
|
||||
*/
|
||||
public function getDotenvVars()
|
||||
public function getDotenvVars(): ParameterBag
|
||||
{
|
||||
return new ParameterBag($this->data['dotenv_vars']->getValue());
|
||||
}
|
||||
|
||||
@@ -48,10 +48,7 @@ class RouterDataCollector extends DataCollector
|
||||
unset($this->controllers[$request]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
public function reset(): void
|
||||
{
|
||||
$this->controllers = new \SplObjectStorage();
|
||||
|
||||
@@ -62,20 +59,15 @@ class RouterDataCollector extends DataCollector
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function guessRoute(Request $request, string|object|array $controller)
|
||||
protected function guessRoute(Request $request, string|object|array $controller): string
|
||||
{
|
||||
return 'n/a';
|
||||
}
|
||||
|
||||
/**
|
||||
* Remembers the controller associated to each request.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onKernelController(ControllerEvent $event)
|
||||
public function onKernelController(ControllerEvent $event): void
|
||||
{
|
||||
$this->controllers[$event->getRequest()] = $event->getController();
|
||||
}
|
||||
|
||||
@@ -49,10 +49,7 @@ class FileLinkFormatter
|
||||
$this->urlFormat = $urlFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|false
|
||||
*/
|
||||
public function format(string $file, int $line): string|bool
|
||||
public function format(string $file, int $line): string|false
|
||||
{
|
||||
if ($fmt = $this->getFileLinkFormat()) {
|
||||
for ($i = 1; isset($fmt[$i]); ++$i) {
|
||||
|
||||
@@ -23,10 +23,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
||||
*/
|
||||
class TraceableEventDispatcher extends BaseTraceableEventDispatcher
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function beforeDispatch(string $eventName, object $event)
|
||||
protected function beforeDispatch(string $eventName, object $event): void
|
||||
{
|
||||
switch ($eventName) {
|
||||
case KernelEvents::REQUEST:
|
||||
@@ -58,10 +55,7 @@ class TraceableEventDispatcher extends BaseTraceableEventDispatcher
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function afterDispatch(string $eventName, object $event)
|
||||
protected function afterDispatch(string $eventName, object $event): void
|
||||
{
|
||||
switch ($eventName) {
|
||||
case KernelEvents::CONTROLLER_ARGUMENTS:
|
||||
|
||||
@@ -31,10 +31,7 @@ class AddAnnotatedClassesToCachePass implements CompilerPassInterface
|
||||
$this->kernel = $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$annotatedClasses = [];
|
||||
foreach ($container->getExtensions() as $extension) {
|
||||
|
||||
@@ -34,8 +34,6 @@ abstract class ConfigurableExtension extends Extension
|
||||
|
||||
/**
|
||||
* Configures the passed container according to the merged configuration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
abstract protected function loadInternal(array $mergedConfig, ContainerBuilder $container);
|
||||
abstract protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void;
|
||||
}
|
||||
|
||||
@@ -30,10 +30,7 @@ class ControllerArgumentValueResolverPass implements CompilerPassInterface
|
||||
{
|
||||
use PriorityTaggedServiceTrait;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('argument_resolver')) {
|
||||
return;
|
||||
|
||||
@@ -34,10 +34,8 @@ abstract class Extension extends BaseExtension
|
||||
* Adds annotated classes to the class cache.
|
||||
*
|
||||
* @param array $annotatedClasses An array of class patterns
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addAnnotatedClassesToCompile(array $annotatedClasses)
|
||||
public function addAnnotatedClassesToCompile(array $annotatedClasses): void
|
||||
{
|
||||
$this->annotatedClasses = array_merge($this->annotatedClasses, $annotatedClasses);
|
||||
}
|
||||
|
||||
@@ -25,10 +25,7 @@ use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;
|
||||
*/
|
||||
class FragmentRendererPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('fragment.handler')) {
|
||||
return;
|
||||
|
||||
@@ -25,10 +25,7 @@ use Symfony\Component\HttpKernel\Log\Logger;
|
||||
*/
|
||||
class LoggerPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$container->setAlias(LoggerInterface::class, 'logger')
|
||||
->setPublic(false);
|
||||
|
||||
@@ -31,10 +31,7 @@ class MergeExtensionConfigurationPass extends BaseMergeExtensionConfigurationPas
|
||||
$this->extensions = $extensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
foreach ($this->extensions as $extension) {
|
||||
if (!\count($container->getExtensionConfig($extension))) {
|
||||
|
||||
@@ -33,10 +33,7 @@ use Symfony\Component\VarExporter\ProxyHelper;
|
||||
*/
|
||||
class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('argument_resolver.service') && !$container->hasDefinition('argument_resolver.not_tagged_controller')) {
|
||||
return;
|
||||
|
||||
@@ -23,10 +23,7 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
*/
|
||||
class RegisterLocaleAwareServicesPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->hasDefinition('locale_aware_listener')) {
|
||||
return;
|
||||
|
||||
@@ -21,10 +21,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
*/
|
||||
class RemoveEmptyControllerArgumentLocatorsPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$controllerLocator = $container->findDefinition('argument_resolver.controller_locator');
|
||||
$controllers = $controllerLocator->getArgument(0);
|
||||
|
||||
@@ -23,10 +23,7 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
*/
|
||||
class ResettableServicePass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
if (!$container->has('services_resetter')) {
|
||||
return;
|
||||
|
||||
@@ -36,10 +36,8 @@ class RequestEvent extends KernelEvent
|
||||
|
||||
/**
|
||||
* Sets a response and stops event propagation.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setResponse(Response $response)
|
||||
public function setResponse(Response $response): void
|
||||
{
|
||||
$this->response = $response;
|
||||
|
||||
|
||||
@@ -46,10 +46,8 @@ class CacheAttributeListener implements EventSubscriberInterface
|
||||
|
||||
/**
|
||||
* Handles HTTP validation headers.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onKernelControllerArguments(ControllerArgumentsEvent $event)
|
||||
public function onKernelControllerArguments(ControllerArgumentsEvent $event): void
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
|
||||
@@ -92,10 +90,8 @@ class CacheAttributeListener implements EventSubscriberInterface
|
||||
|
||||
/**
|
||||
* Modifies the response to apply HTTP cache headers when needed.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function onKernelResponse(ResponseEvent $event)
|
||||
public function onKernelResponse(ResponseEvent $event): void
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
|
||||
|
||||
@@ -36,10 +36,7 @@ class DumpListener implements EventSubscriberInterface
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function configure()
|
||||
public function configure(): void
|
||||
{
|
||||
$cloner = $this->cloner;
|
||||
$dumper = $this->dumper;
|
||||
|
||||
@@ -51,10 +51,7 @@ class ErrorListener implements EventSubscriberInterface
|
||||
$this->exceptionsMapping = $exceptionsMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function logKernelException(ExceptionEvent $event)
|
||||
public function logKernelException(ExceptionEvent $event): void
|
||||
{
|
||||
$throwable = $event->getThrowable();
|
||||
$logLevel = $this->resolveLogLevel($throwable);
|
||||
@@ -92,10 +89,7 @@ class ErrorListener implements EventSubscriberInterface
|
||||
$this->logException($throwable, sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', $e->getClass(), $e->getMessage(), $e->getFile(), $e->getLine()), $logLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function onKernelException(ExceptionEvent $event)
|
||||
public function onKernelException(ExceptionEvent $event): void
|
||||
{
|
||||
if (null === $this->controller) {
|
||||
return;
|
||||
@@ -138,10 +132,7 @@ class ErrorListener implements EventSubscriberInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function onControllerArguments(ControllerArgumentsEvent $event)
|
||||
public function onControllerArguments(ControllerArgumentsEvent $event): void
|
||||
{
|
||||
$e = $event->getRequest()->attributes->get('exception');
|
||||
|
||||
|
||||
@@ -39,10 +39,7 @@ class HttpException extends \RuntimeException implements HttpExceptionInterface
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setHeaders(array $headers)
|
||||
public function setHeaders(array $headers): void
|
||||
{
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
@@ -48,10 +48,8 @@ class FragmentHandler
|
||||
|
||||
/**
|
||||
* Adds a renderer.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addRenderer(FragmentRendererInterface $renderer)
|
||||
public function addRenderer(FragmentRendererInterface $renderer): void
|
||||
{
|
||||
$this->renderers[$renderer->getName()] = $renderer;
|
||||
}
|
||||
|
||||
@@ -103,10 +103,7 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Request
|
||||
*/
|
||||
protected function createSubRequest(string $uri, Request $request)
|
||||
protected function createSubRequest(string $uri, Request $request): Request
|
||||
{
|
||||
$cookies = $request->cookies->all();
|
||||
$server = $request->server->all();
|
||||
|
||||
@@ -31,10 +31,8 @@ abstract class RoutableFragmentRenderer implements FragmentRendererInterface
|
||||
* Sets the fragment path that triggers the fragment listener.
|
||||
*
|
||||
* @see FragmentListener
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setFragmentPath(string $path)
|
||||
public function setFragmentPath(string $path): void
|
||||
{
|
||||
$this->fragmentPath = $path;
|
||||
}
|
||||
|
||||
@@ -51,10 +51,7 @@ abstract class AbstractSurrogate implements SurrogateInterface
|
||||
return str_contains($value, sprintf('%s/1.0', strtoupper($this->getName())));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function addSurrogateCapability(Request $request)
|
||||
public function addSurrogateCapability(Request $request): void
|
||||
{
|
||||
$current = $request->headers->get('Surrogate-Capability');
|
||||
$new = sprintf('symfony="%s/1.0"', strtoupper($this->getName()));
|
||||
@@ -100,10 +97,8 @@ abstract class AbstractSurrogate implements SurrogateInterface
|
||||
|
||||
/**
|
||||
* Remove the Surrogate from the Surrogate-Control header.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function removeFromControl(Response $response)
|
||||
protected function removeFromControl(Response $response): void
|
||||
{
|
||||
if (!$response->headers->has('Surrogate-Control')) {
|
||||
return;
|
||||
|
||||
@@ -32,10 +32,7 @@ class Esi extends AbstractSurrogate
|
||||
return 'esi';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function addSurrogateControl(Response $response)
|
||||
public function addSurrogateControl(Response $response): void
|
||||
{
|
||||
if (str_contains($response->getContent(), '<esi:include')) {
|
||||
$response->headers->set('Surrogate-Control', 'content="ESI/1.0"');
|
||||
|
||||
@@ -236,10 +236,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function terminate(Request $request, Response $response)
|
||||
public function terminate(Request $request, Response $response): void
|
||||
{
|
||||
// Do not call any listeners in case of a cache hit.
|
||||
// This ensures identical behavior as if you had a separate
|
||||
@@ -454,10 +451,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
*
|
||||
* @param bool $catch Whether to catch exceptions or not
|
||||
* @param Response|null $entry A Response instance (the stale entry if present, null otherwise)
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function forward(Request $request, bool $catch = false, Response $entry = null)
|
||||
protected function forward(Request $request, bool $catch = false, Response $entry = null): Response
|
||||
{
|
||||
$this->surrogate?->addSurrogateCapability($request);
|
||||
|
||||
@@ -587,11 +582,9 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
/**
|
||||
* Writes the Response to the cache.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function store(Request $request, Response $response)
|
||||
protected function store(Request $request, Response $response): void
|
||||
{
|
||||
try {
|
||||
$restoreHeaders = [];
|
||||
@@ -666,10 +659,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
|
||||
$response->headers->remove('X-Body-File');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
protected function processResponseBody(Request $request, Response $response)
|
||||
protected function processResponseBody(Request $request, Response $response): void
|
||||
{
|
||||
if ($this->surrogate?->needsParsing($response)) {
|
||||
$this->surrogate->process($request, $response);
|
||||
|
||||
@@ -54,10 +54,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
'expires' => null,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function add(Response $response)
|
||||
public function add(Response $response): void
|
||||
{
|
||||
++$this->embeddedResponses;
|
||||
|
||||
@@ -98,10 +95,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function update(Response $response)
|
||||
public function update(Response $response): void
|
||||
{
|
||||
// if we have no embedded Response, do nothing
|
||||
if (0 === $this->embeddedResponses) {
|
||||
|
||||
@@ -27,15 +27,11 @@ interface ResponseCacheStrategyInterface
|
||||
{
|
||||
/**
|
||||
* Adds a Response.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add(Response $response);
|
||||
public function add(Response $response): void;
|
||||
|
||||
/**
|
||||
* Updates the Response HTTP headers based on the embedded Responses.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function update(Response $response);
|
||||
public function update(Response $response): void;
|
||||
}
|
||||
|
||||
@@ -26,10 +26,7 @@ class Ssi extends AbstractSurrogate
|
||||
return 'ssi';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function addSurrogateControl(Response $response)
|
||||
public function addSurrogateControl(Response $response): void
|
||||
{
|
||||
if (str_contains($response->getContent(), '<!--#include')) {
|
||||
$response->headers->set('Surrogate-Control', 'content="SSI/1.0"');
|
||||
|
||||
@@ -55,10 +55,8 @@ class Store implements StoreInterface
|
||||
|
||||
/**
|
||||
* Cleanups storage.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cleanup()
|
||||
public function cleanup(): void
|
||||
{
|
||||
// unlock everything
|
||||
foreach ($this->locks as $lock) {
|
||||
@@ -249,11 +247,9 @@ class Store implements StoreInterface
|
||||
/**
|
||||
* Invalidates all cache entries that match the request.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function invalidate(Request $request)
|
||||
public function invalidate(Request $request): void
|
||||
{
|
||||
$modified = false;
|
||||
$key = $this->getCacheKey($request);
|
||||
@@ -417,10 +413,7 @@ class Store implements StoreInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPath(string $key)
|
||||
public function getPath(string $key): string
|
||||
{
|
||||
return $this->root.\DIRECTORY_SEPARATOR.substr($key, 0, 2).\DIRECTORY_SEPARATOR.substr($key, 2, 2).\DIRECTORY_SEPARATOR.substr($key, 4, 2).\DIRECTORY_SEPARATOR.substr($key, 6);
|
||||
}
|
||||
|
||||
@@ -41,10 +41,8 @@ interface StoreInterface
|
||||
|
||||
/**
|
||||
* Invalidates all cache entries that match the request.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function invalidate(Request $request);
|
||||
public function invalidate(Request $request): void;
|
||||
|
||||
/**
|
||||
* Locks the cache for a given Request.
|
||||
@@ -76,8 +74,6 @@ interface StoreInterface
|
||||
|
||||
/**
|
||||
* Cleanups storage.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cleanup();
|
||||
public function cleanup(): void;
|
||||
}
|
||||
|
||||
@@ -33,19 +33,15 @@ interface SurrogateInterface
|
||||
|
||||
/**
|
||||
* Adds Surrogate-capability to the given Request.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addSurrogateCapability(Request $request);
|
||||
public function addSurrogateCapability(Request $request): void;
|
||||
|
||||
/**
|
||||
* Adds HTTP headers to specify that the Response needs to be parsed for Surrogate.
|
||||
*
|
||||
* This method only adds an Surrogate HTTP header if the Response has some Surrogate tags.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addSurrogateControl(Response $response);
|
||||
public function addSurrogateControl(Response $response): void;
|
||||
|
||||
/**
|
||||
* Checks that the Response needs to be parsed for Surrogate tags.
|
||||
|
||||
@@ -92,10 +92,7 @@ class HttpKernel implements HttpKernelInterface, TerminableInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function terminate(Request $request, Response $response)
|
||||
public function terminate(Request $request, Response $response): void
|
||||
{
|
||||
$this->dispatcher->dispatch(new TerminateEvent($this, $request, $response), KernelEvents::TERMINATE);
|
||||
}
|
||||
|
||||
@@ -47,20 +47,16 @@ class HttpKernelBrowser extends AbstractBrowser
|
||||
|
||||
/**
|
||||
* Sets whether to catch exceptions when the kernel is handling a request.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function catchExceptions(bool $catchExceptions)
|
||||
public function catchExceptions(bool $catchExceptions): void
|
||||
{
|
||||
$this->catchExceptions = $catchExceptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
protected function doRequest(object $request)
|
||||
protected function doRequest(object $request): Response
|
||||
{
|
||||
$response = $this->kernel->handle($request, HttpKernelInterface::MAIN_REQUEST, $this->catchExceptions);
|
||||
|
||||
@@ -73,10 +69,8 @@ class HttpKernelBrowser extends AbstractBrowser
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getScript(object $request)
|
||||
protected function getScript(object $request): string
|
||||
{
|
||||
$kernel = var_export(serialize($this->kernel), true);
|
||||
$request = var_export(serialize($request), true);
|
||||
@@ -112,10 +106,7 @@ EOF;
|
||||
return $code.$this->getHandleScript();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getHandleScript()
|
||||
protected function getHandleScript(): string
|
||||
{
|
||||
return <<<'EOF'
|
||||
$response = $kernel->handle($request);
|
||||
|
||||
45
Kernel.php
45
Kernel.php
@@ -103,10 +103,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
$this->resetServices = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
public function boot(): void
|
||||
{
|
||||
if (true === $this->booted) {
|
||||
if (!$this->requestStackSize && $this->resetServices) {
|
||||
@@ -134,20 +131,14 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
$this->booted = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reboot(?string $warmupDir)
|
||||
public function reboot(?string $warmupDir): void
|
||||
{
|
||||
$this->shutdown();
|
||||
$this->warmupDir = $warmupDir;
|
||||
$this->boot();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function terminate(Request $request, Response $response)
|
||||
public function terminate(Request $request, Response $response): void
|
||||
{
|
||||
if (false === $this->booted) {
|
||||
return;
|
||||
@@ -158,10 +149,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function shutdown()
|
||||
public function shutdown(): void
|
||||
{
|
||||
if (false === $this->booted) {
|
||||
return;
|
||||
@@ -335,11 +323,9 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
/**
|
||||
* Initializes bundles.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws \LogicException if two bundles share a common name
|
||||
*/
|
||||
protected function initializeBundles()
|
||||
protected function initializeBundles(): void
|
||||
{
|
||||
// init bundles
|
||||
$this->bundles = [];
|
||||
@@ -356,10 +342,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
* The extension point similar to the Bundle::build() method.
|
||||
*
|
||||
* Use this method to register compiler passes and manipulate the container during the building process.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function build(ContainerBuilder $container)
|
||||
protected function build(ContainerBuilder $container): void
|
||||
{
|
||||
}
|
||||
|
||||
@@ -396,10 +380,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
*
|
||||
* The built version of the service container is used when fresh, otherwise the
|
||||
* container is built.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function initializeContainer()
|
||||
protected function initializeContainer(): void
|
||||
{
|
||||
$class = $this->getContainerClass();
|
||||
$buildDir = $this->warmupDir ?: $this->getBuildDir();
|
||||
@@ -610,10 +592,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
|
||||
/**
|
||||
* Prepares the ContainerBuilder before it is compiled.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function prepareContainer(ContainerBuilder $container)
|
||||
protected function prepareContainer(ContainerBuilder $container): void
|
||||
{
|
||||
$extensions = [];
|
||||
foreach ($this->bundles as $bundle) {
|
||||
@@ -663,10 +643,8 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
*
|
||||
* @param string $class The name of the class to generate
|
||||
* @param string $baseClass The name of the container's base class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, string $class, string $baseClass)
|
||||
protected function dumpContainer(ConfigCache $cache, ContainerBuilder $container, string $class, string $baseClass): void
|
||||
{
|
||||
// cache the container
|
||||
$dumper = new PhpDumper($container);
|
||||
@@ -819,10 +797,7 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
return ['environment', 'debug'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup()
|
||||
public function __wakeup(): void
|
||||
{
|
||||
if (\is_object($this->environment) || \is_object($this->debug)) {
|
||||
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
|
||||
|
||||
@@ -33,26 +33,20 @@ interface KernelInterface extends HttpKernelInterface
|
||||
|
||||
/**
|
||||
* Loads the container configuration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function registerContainerConfiguration(LoaderInterface $loader);
|
||||
public function registerContainerConfiguration(LoaderInterface $loader): void;
|
||||
|
||||
/**
|
||||
* Boots the current kernel.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot();
|
||||
public function boot(): void;
|
||||
|
||||
/**
|
||||
* Shutdowns the kernel.
|
||||
*
|
||||
* This method is mainly useful when doing functional testing.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function shutdown();
|
||||
public function shutdown(): void;
|
||||
|
||||
/**
|
||||
* Gets the registered bundle instances.
|
||||
|
||||
@@ -33,19 +33,15 @@ interface DebugLoggerInterface
|
||||
* timestamp_rfc3339: string,
|
||||
* }>
|
||||
*/
|
||||
public function getLogs(Request $request = null);
|
||||
public function getLogs(Request $request = null): array;
|
||||
|
||||
/**
|
||||
* Returns the number of errors.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function countErrors(Request $request = null);
|
||||
public function countErrors(Request $request = null): int;
|
||||
|
||||
/**
|
||||
* Removes all log records.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function clear();
|
||||
public function clear(): void;
|
||||
}
|
||||
|
||||
@@ -87,10 +87,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
return array_values($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function purge()
|
||||
public function purge(): void
|
||||
{
|
||||
$flags = \FilesystemIterator::SKIP_DOTS;
|
||||
$iterator = new \RecursiveDirectoryIterator($this->folder, $flags);
|
||||
@@ -245,10 +242,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
return '' === $line ? null : $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Profile
|
||||
*/
|
||||
protected function createProfileFromData(string $token, array $data, Profile $parent = null)
|
||||
protected function createProfileFromData(string $token, array $data, Profile $parent = null): Profile
|
||||
{
|
||||
$profile = new Profile($token);
|
||||
$profile->setIp($data['ip']);
|
||||
|
||||
@@ -44,10 +44,7 @@ class Profile
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setToken(string $token)
|
||||
public function setToken(string $token): void
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
@@ -62,10 +59,8 @@ class Profile
|
||||
|
||||
/**
|
||||
* Sets the parent token.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setParent(self $parent)
|
||||
public function setParent(self $parent): void
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
@@ -94,10 +89,7 @@ class Profile
|
||||
return $this->ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setIp(?string $ip)
|
||||
public function setIp(?string $ip): void
|
||||
{
|
||||
$this->ip = $ip;
|
||||
}
|
||||
@@ -110,10 +102,7 @@ class Profile
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setMethod(string $method)
|
||||
public function setMethod(string $method): void
|
||||
{
|
||||
$this->method = $method;
|
||||
}
|
||||
@@ -126,10 +115,7 @@ class Profile
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setUrl(?string $url)
|
||||
public function setUrl(?string $url): void
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
@@ -139,18 +125,12 @@ class Profile
|
||||
return $this->time ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setTime(int $time)
|
||||
public function setTime(int $time): void
|
||||
{
|
||||
$this->time = $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setStatusCode(int $statusCode)
|
||||
public function setStatusCode(int $statusCode): void
|
||||
{
|
||||
$this->statusCode = $statusCode;
|
||||
}
|
||||
@@ -174,10 +154,8 @@ class Profile
|
||||
* Sets children profiler.
|
||||
*
|
||||
* @param Profile[] $children
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setChildren(array $children)
|
||||
public function setChildren(array $children): void
|
||||
{
|
||||
$this->children = [];
|
||||
foreach ($children as $child) {
|
||||
@@ -187,10 +165,8 @@ class Profile
|
||||
|
||||
/**
|
||||
* Adds the child token.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addChild(self $child)
|
||||
public function addChild(self $child): void
|
||||
{
|
||||
$this->children[] = $child;
|
||||
$child->setParent($this);
|
||||
@@ -235,10 +211,8 @@ class Profile
|
||||
* Sets the Collectors associated with this profile.
|
||||
*
|
||||
* @param DataCollectorInterface[] $collectors
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setCollectors(array $collectors)
|
||||
public function setCollectors(array $collectors): void
|
||||
{
|
||||
$this->collectors = [];
|
||||
foreach ($collectors as $collector) {
|
||||
@@ -248,10 +222,8 @@ class Profile
|
||||
|
||||
/**
|
||||
* Adds a Collector.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addCollector(DataCollectorInterface $collector)
|
||||
public function addCollector(DataCollectorInterface $collector): void
|
||||
{
|
||||
$this->collectors[$collector->getName()] = $collector;
|
||||
}
|
||||
|
||||
@@ -46,20 +46,16 @@ class Profiler implements ResetInterface
|
||||
|
||||
/**
|
||||
* Disables the profiler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disable()
|
||||
public function disable(): void
|
||||
{
|
||||
$this->enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the profiler.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enable()
|
||||
public function enable(): void
|
||||
{
|
||||
$this->enabled = true;
|
||||
}
|
||||
@@ -110,10 +106,8 @@ class Profiler implements ResetInterface
|
||||
|
||||
/**
|
||||
* Purges all data from the storage.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function purge()
|
||||
public function purge(): void
|
||||
{
|
||||
$this->storage->purge();
|
||||
}
|
||||
@@ -168,10 +162,7 @@ class Profiler implements ResetInterface
|
||||
return $profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function reset()
|
||||
public function reset(): void
|
||||
{
|
||||
foreach ($this->collectors as $collector) {
|
||||
$collector->reset();
|
||||
@@ -191,10 +182,8 @@ class Profiler implements ResetInterface
|
||||
* Sets the Collectors associated with this profiler.
|
||||
*
|
||||
* @param DataCollectorInterface[] $collectors An array of collectors
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set(array $collectors = [])
|
||||
public function set(array $collectors = []): void
|
||||
{
|
||||
$this->collectors = [];
|
||||
foreach ($collectors as $collector) {
|
||||
@@ -204,10 +193,8 @@ class Profiler implements ResetInterface
|
||||
|
||||
/**
|
||||
* Adds a Collector.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add(DataCollectorInterface $collector)
|
||||
public function add(DataCollectorInterface $collector): void
|
||||
{
|
||||
$this->collectors[$collector->getName()] = $collector;
|
||||
}
|
||||
|
||||
@@ -49,8 +49,6 @@ interface ProfilerStorageInterface
|
||||
|
||||
/**
|
||||
* Purges all data from the database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function purge();
|
||||
public function purge(): void;
|
||||
}
|
||||
|
||||
@@ -25,8 +25,6 @@ interface RebootableInterface
|
||||
* while building the container. Use the %kernel.build_dir% parameter instead.
|
||||
*
|
||||
* @param string|null $warmupDir pass null to reboot in the regular build directory
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function reboot(?string $warmupDir);
|
||||
public function reboot(?string $warmupDir): void;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@ interface TerminableInterface
|
||||
* Terminates a request/response cycle.
|
||||
*
|
||||
* Should be called after sending the response and before shutting down the kernel.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function terminate(Request $request, Response $response);
|
||||
public function terminate(Request $request, Response $response): void;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class TraceableArgumentResolverTest extends TestCase
|
||||
$stopwatch->method('start')->willReturn($stopwatchEvent);
|
||||
|
||||
$resolver = new class() implements ArgumentResolverInterface {
|
||||
public function getArguments(Request $request, callable $controller, ?\ReflectionFunctionAbstract $reflector = null): array
|
||||
public function getArguments(Request $request, callable $controller, \ReflectionFunctionAbstract $reflector = null): array
|
||||
{
|
||||
throw new \Exception();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user