diff options
Diffstat (limited to 'vendor/symfony/http-kernel/HttpCache')
7 files changed, 40 insertions, 40 deletions
diff --git a/vendor/symfony/http-kernel/HttpCache/AbstractSurrogate.php b/vendor/symfony/http-kernel/HttpCache/AbstractSurrogate.php index 3b2d5f262c..8918a30570 100644 --- a/vendor/symfony/http-kernel/HttpCache/AbstractSurrogate.php +++ b/vendor/symfony/http-kernel/HttpCache/AbstractSurrogate.php @@ -24,16 +24,16 @@ use Symfony\Component\HttpKernel\HttpKernelInterface; abstract class AbstractSurrogate implements SurrogateInterface { protected $contentTypes; - protected $phpEscapeMap = array( - array('<?', '<%', '<s', '<S'), - array('<?php echo "<?"; ?>', '<?php echo "<%"; ?>', '<?php echo "<s"; ?>', '<?php echo "<S"; ?>'), - ); + protected $phpEscapeMap = [ + ['<?', '<%', '<s', '<S'], + ['<?php echo "<?"; ?>', '<?php echo "<%"; ?>', '<?php echo "<s"; ?>', '<?php echo "<S"; ?>'], + ]; /** * @param array $contentTypes An array of content-type that should be parsed for Surrogate information * (default: text/html, text/xml, application/xhtml+xml, and application/xml) */ - public function __construct(array $contentTypes = array('text/html', 'text/xml', 'application/xhtml+xml', 'application/xml')) + public function __construct(array $contentTypes = ['text/html', 'text/xml', 'application/xhtml+xml', 'application/xml']) { $this->contentTypes = $contentTypes; } @@ -90,7 +90,7 @@ abstract class AbstractSurrogate implements SurrogateInterface */ public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors) { - $subRequest = Request::create($uri, Request::METHOD_GET, array(), $cache->getRequest()->cookies->all(), array(), $cache->getRequest()->server->all()); + $subRequest = Request::create($uri, Request::METHOD_GET, [], $cache->getRequest()->cookies->all(), [], $cache->getRequest()->server->all()); try { $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true); diff --git a/vendor/symfony/http-kernel/HttpCache/Esi.php b/vendor/symfony/http-kernel/HttpCache/Esi.php index 69134c71a1..dc62990b40 100644 --- a/vendor/symfony/http-kernel/HttpCache/Esi.php +++ b/vendor/symfony/http-kernel/HttpCache/Esi.php @@ -85,7 +85,7 @@ class Esi extends AbstractSurrogate $i = 1; while (isset($chunks[$i])) { - $options = array(); + $options = []; preg_match_all('/(src|onerror|alt)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); foreach ($matches as $set) { $options[$set[1]] = $set[2]; diff --git a/vendor/symfony/http-kernel/HttpCache/HttpCache.php b/vendor/symfony/http-kernel/HttpCache/HttpCache.php index 6980745add..84b01659f9 100644 --- a/vendor/symfony/http-kernel/HttpCache/HttpCache.php +++ b/vendor/symfony/http-kernel/HttpCache/HttpCache.php @@ -32,8 +32,8 @@ class HttpCache implements HttpKernelInterface, TerminableInterface private $request; private $surrogate; private $surrogateCacheStrategy; - private $options = array(); - private $traces = array(); + private $options = []; + private $traces = []; /** * Constructor. @@ -70,24 +70,24 @@ class HttpCache implements HttpKernelInterface, TerminableInterface * This setting is overridden by the stale-if-error HTTP Cache-Control extension * (see RFC 5861). */ - public function __construct(HttpKernelInterface $kernel, StoreInterface $store, SurrogateInterface $surrogate = null, array $options = array()) + public function __construct(HttpKernelInterface $kernel, StoreInterface $store, SurrogateInterface $surrogate = null, array $options = []) { $this->store = $store; $this->kernel = $kernel; $this->surrogate = $surrogate; // needed in case there is a fatal error because the backend is too slow to respond - register_shutdown_function(array($this->store, 'cleanup')); + register_shutdown_function([$this->store, 'cleanup']); - $this->options = array_merge(array( + $this->options = array_merge([ 'debug' => false, 'default_ttl' => 0, - 'private_headers' => array('Authorization', 'Cookie'), + 'private_headers' => ['Authorization', 'Cookie'], 'allow_reload' => false, 'allow_revalidate' => false, 'stale_while_revalidate' => 2, 'stale_if_error' => 60, - ), $options); + ], $options); } /** @@ -117,7 +117,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface */ public function getLog() { - $log = array(); + $log = []; foreach ($this->traces as $request => $traces) { $log[] = sprintf('%s: %s', $request, implode(', ', $traces)); } @@ -164,7 +164,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface { // FIXME: catch exceptions and implement a 500 error page here? -> in Varnish, there is a built-in error page mechanism if (HttpKernelInterface::MASTER_REQUEST === $type) { - $this->traces = array(); + $this->traces = []; // Keep a clone of the original request for surrogates so they can access it. // We must clone here to get a separate instance because the application will modify the request during // the application flow (we know it always does because we do ourselves by setting REMOTE_ADDR to 127.0.0.1 @@ -175,7 +175,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface } } - $this->traces[$this->getTraceKey($request)] = array(); + $this->traces[$this->getTraceKey($request)] = []; if (!$request->isMethodSafe(false)) { $response = $this->invalidate($request, $catch); @@ -260,9 +260,9 @@ class HttpCache implements HttpKernelInterface, TerminableInterface $this->store->invalidate($request); // As per the RFC, invalidate Location and Content-Location URLs if present - foreach (array('Location', 'Content-Location') as $header) { + foreach (['Location', 'Content-Location'] as $header) { if ($uri = $response->headers->get($header)) { - $subRequest = Request::create($uri, 'get', array(), array(), array(), $request->server->all()); + $subRequest = Request::create($uri, 'get', [], [], [], $request->server->all()); $this->store->invalidate($subRequest); } @@ -357,7 +357,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface // Add our cached etag validator to the environment. // We keep the etags from the client to handle the case when the client // has a different private valid entry which is not cached here. - $cachedEtags = $entry->getEtag() ? array($entry->getEtag()) : array(); + $cachedEtags = $entry->getEtag() ? [$entry->getEtag()] : []; $requestEtags = $request->getETags(); if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) { $subRequest->headers->set('if_none_match', implode(', ', $etags)); @@ -377,7 +377,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface $entry = clone $entry; $entry->headers->remove('Date'); - foreach (array('Date', 'Expires', 'Cache-Control', 'ETag', 'Last-Modified') as $name) { + foreach (['Date', 'Expires', 'Cache-Control', 'ETag', 'Last-Modified'] as $name) { if ($response->headers->has($name)) { $entry->headers->set($name, $response->headers->get($name)); } @@ -448,7 +448,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface $response = SubRequestHandler::handle($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $catch); // we don't implement the stale-if-error on Requests, which is nonetheless part of the RFC - if (null !== $entry && \in_array($response->getStatusCode(), array(500, 502, 503, 504))) { + if (null !== $entry && \in_array($response->getStatusCode(), [500, 502, 503, 504])) { if (null === $age = $entry->headers->getCacheControlDirective('stale-if-error')) { $age = $this->options['stale_if_error']; } diff --git a/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategy.php b/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategy.php index 672cc893fe..168e9564b0 100644 --- a/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategy.php +++ b/vendor/symfony/http-kernel/HttpCache/ResponseCacheStrategy.php @@ -30,8 +30,8 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface { private $cacheable = true; private $embeddedResponses = 0; - private $ttls = array(); - private $maxAges = array(); + private $ttls = []; + private $maxAges = []; private $isNotCacheableResponseEmbedded = false; /** diff --git a/vendor/symfony/http-kernel/HttpCache/Ssi.php b/vendor/symfony/http-kernel/HttpCache/Ssi.php index 58df176019..eaaa230b50 100644 --- a/vendor/symfony/http-kernel/HttpCache/Ssi.php +++ b/vendor/symfony/http-kernel/HttpCache/Ssi.php @@ -70,7 +70,7 @@ class Ssi extends AbstractSurrogate $i = 1; while (isset($chunks[$i])) { - $options = array(); + $options = []; preg_match_all('/(virtual)="([^"]*?)"/', $chunks[$i], $matches, PREG_SET_ORDER); foreach ($matches as $set) { $options[$set[1]] = $set[2]; diff --git a/vendor/symfony/http-kernel/HttpCache/Store.php b/vendor/symfony/http-kernel/HttpCache/Store.php index 925ca96fd4..0ca14c7590 100644 --- a/vendor/symfony/http-kernel/HttpCache/Store.php +++ b/vendor/symfony/http-kernel/HttpCache/Store.php @@ -38,7 +38,7 @@ class Store implements StoreInterface throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root)); } $this->keyCache = new \SplObjectStorage(); - $this->locks = array(); + $this->locks = []; } /** @@ -52,7 +52,7 @@ class Store implements StoreInterface fclose($lock); } - $this->locks = array(); + $this->locks = []; } /** @@ -190,11 +190,11 @@ class Store implements StoreInterface } // read existing cache entries, remove non-varying, and add this one to the list - $entries = array(); + $entries = []; $vary = $response->headers->get('vary'); foreach ($this->getMetadata($key) as $entry) { if (!isset($entry[1]['vary'][0])) { - $entry[1]['vary'] = array(''); + $entry[1]['vary'] = ['']; } if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary, $entry[0], $storedEnv)) { @@ -205,7 +205,7 @@ class Store implements StoreInterface $headers = $this->persistResponse($response); unset($headers['age']); - array_unshift($entries, array($storedEnv, $headers)); + array_unshift($entries, [$storedEnv, $headers]); if (false === $this->save($key, serialize($entries))) { throw new \RuntimeException('Unable to store the metadata.'); @@ -234,13 +234,13 @@ class Store implements StoreInterface $modified = false; $key = $this->getCacheKey($request); - $entries = array(); + $entries = []; foreach ($this->getMetadata($key) as $entry) { $response = $this->restoreResponse($entry[1]); if ($response->isFresh()) { $response->expire(); $modified = true; - $entries[] = array($entry[0], $this->persistResponse($response)); + $entries[] = [$entry[0], $this->persistResponse($response)]; } else { $entries[] = $entry; } @@ -291,7 +291,7 @@ class Store implements StoreInterface private function getMetadata($key) { if (!$entries = $this->load($key)) { - return array(); + return []; } return unserialize($entries); @@ -462,7 +462,7 @@ class Store implements StoreInterface private function persistResponse(Response $response) { $headers = $response->headers->all(); - $headers['X-Status'] = array($response->getStatusCode()); + $headers['X-Status'] = [$response->getStatusCode()]; return $headers; } @@ -481,7 +481,7 @@ class Store implements StoreInterface unset($headers['X-Status']); if (null !== $body) { - $headers['X-Body-File'] = array($body); + $headers['X-Body-File'] = [$body]; } return new Response($body, $status, $headers); diff --git a/vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php b/vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php index 84d7a84e79..cef9817e01 100644 --- a/vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php +++ b/vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php @@ -32,13 +32,13 @@ class SubRequestHandler // remove untrusted values $remoteAddr = $request->server->get('REMOTE_ADDR'); if (!IpUtils::checkIp($remoteAddr, $trustedProxies)) { - $trustedHeaders = array( + $trustedHeaders = [ 'FORWARDED' => $trustedHeaderSet & Request::HEADER_FORWARDED, 'X_FORWARDED_FOR' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_FOR, 'X_FORWARDED_HOST' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_HOST, 'X_FORWARDED_PROTO' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_PROTO, 'X_FORWARDED_PORT' => $trustedHeaderSet & Request::HEADER_X_FORWARDED_PORT, - ); + ]; foreach (array_filter($trustedHeaders) as $name => $key) { $request->headers->remove($name); $request->server->remove('HTTP_'.$name); @@ -46,8 +46,8 @@ class SubRequestHandler } // compute trusted values, taking any trusted proxies into account - $trustedIps = array(); - $trustedValues = array(); + $trustedIps = []; + $trustedValues = []; foreach (array_reverse($request->getClientIps()) as $ip) { $trustedIps[] = $ip; $trustedValues[] = sprintf('for="%s"', $ip); @@ -78,7 +78,7 @@ class SubRequestHandler // ensure 127.0.0.1 is set as trusted proxy if (!IpUtils::checkIp('127.0.0.1', $trustedProxies)) { - Request::setTrustedProxies(array_merge($trustedProxies, array('127.0.0.1')), Request::getTrustedHeaderSet()); + Request::setTrustedProxies(array_merge($trustedProxies, ['127.0.0.1']), Request::getTrustedHeaderSet()); } try { |
