upgrade to laravel 7 and set branch to v2

This commit is contained in:
2020-12-25 11:22:15 +00:00
parent 516105c492
commit 0ddd298350
4638 changed files with 132501 additions and 190226 deletions

View File

@@ -88,7 +88,7 @@ abstract class AbstractSurrogate implements SurrogateInterface
/**
* {@inheritdoc}
*/
public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors)
public function handle(HttpCache $cache, string $uri, string $alt, bool $ignoreErrors)
{
$subRequest = Request::create($uri, Request::METHOD_GET, [], $cache->getRequest()->cookies->all(), [], $cache->getRequest()->server->all());

View File

@@ -45,7 +45,7 @@ class Esi extends AbstractSurrogate
/**
* {@inheritdoc}
*/
public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '')
public function renderIncludeTag(string $uri, string $alt = null, bool $ignoreErrors = true, string $comment = '')
{
$html = sprintf('<esi:include src="%s"%s%s />',
$uri,

View File

@@ -190,7 +190,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
public function handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true)
{
// 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) {
@@ -260,7 +260,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
*
* @return Response A Response instance
*/
protected function pass(Request $request, $catch = false)
protected function pass(Request $request, bool $catch = false)
{
$this->record($request, 'pass');
@@ -278,7 +278,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
*
* @see RFC2616 13.10
*/
protected function invalidate(Request $request, $catch = false)
protected function invalidate(Request $request, bool $catch = false)
{
$response = $this->pass($request, $catch);
@@ -324,7 +324,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
*
* @throws \Exception
*/
protected function lookup(Request $request, $catch = false)
protected function lookup(Request $request, bool $catch = false)
{
try {
$entry = $this->store->lookup($request);
@@ -371,7 +371,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
*
* @return Response A Response instance
*/
protected function validate(Request $request, Response $entry, $catch = false)
protected function validate(Request $request, Response $entry, bool $catch = false)
{
$subRequest = clone $request;
@@ -434,7 +434,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
*
* @return Response A Response instance
*/
protected function fetch(Request $request, $catch = false)
protected function fetch(Request $request, bool $catch = false)
{
$subRequest = clone $request;
@@ -467,7 +467,7 @@ class HttpCache implements HttpKernelInterface, TerminableInterface
*
* @return Response A Response instance
*/
protected function forward(Request $request, $catch = false, Response $entry = null)
protected function forward(Request $request, bool $catch = false, Response $entry = null)
{
if ($this->surrogate) {
$this->surrogate->addSurrogateCapability($request);

View File

@@ -42,7 +42,7 @@ class Ssi extends AbstractSurrogate
/**
* {@inheritdoc}
*/
public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '')
public function renderIncludeTag(string $uri, string $alt = null, bool $ignoreErrors = true, string $comment = '')
{
return sprintf('<!--#include virtual="%s" -->', $uri);
}

View File

@@ -34,7 +34,7 @@ class Store implements StoreInterface
public function __construct(string $root)
{
$this->root = $root;
if (!file_exists($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) {
if (!is_dir($this->root) && !@mkdir($this->root, 0777, true) && !is_dir($this->root)) {
throw new \RuntimeException(sprintf('Unable to create the store directory (%s).', $this->root));
}
$this->keyCache = new \SplObjectStorage();
@@ -66,7 +66,7 @@ class Store implements StoreInterface
if (!isset($this->locks[$key])) {
$path = $this->getPath($key);
if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
return $path;
}
$h = fopen($path, 'cb');
@@ -110,7 +110,7 @@ class Store implements StoreInterface
return true; // shortcut if lock held by this process
}
if (!file_exists($path = $this->getPath($key))) {
if (!is_file($path = $this->getPath($key))) {
return false;
}
@@ -207,7 +207,7 @@ class Store implements StoreInterface
$entry[1]['vary'] = [''];
}
if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary, $entry[0], $storedEnv)) {
if ($entry[1]['vary'][0] != $vary || !$this->requestsMatch($vary ?? '', $entry[0], $storedEnv)) {
$entries[] = $entry;
}
}
@@ -265,9 +265,9 @@ class Store implements StoreInterface
* Determines whether two Request HTTP header sets are non-varying based on
* the vary response header value provided.
*
* @param string $vary A Response vary header
* @param array $env1 A Request HTTP header array
* @param array $env2 A Request HTTP header array
* @param string|null $vary A Response vary header
* @param array $env1 A Request HTTP header array
* @param array $env2 A Request HTTP header array
*/
private function requestsMatch(?string $vary, array $env1, array $env2): bool
{
@@ -306,11 +306,9 @@ class Store implements StoreInterface
*
* This method purges both the HTTP and the HTTPS version of the cache entry.
*
* @param string $url A URL
*
* @return bool true if the URL exists with either HTTP or HTTPS scheme and has been purged, false otherwise
*/
public function purge($url)
public function purge(string $url)
{
$http = preg_replace('#^https:#', 'http:', $url);
$https = preg_replace('#^http:#', 'https:', $url);
@@ -333,7 +331,7 @@ class Store implements StoreInterface
unset($this->locks[$key]);
}
if (file_exists($path = $this->getPath($key))) {
if (is_file($path = $this->getPath($key))) {
unlink($path);
return true;
@@ -349,7 +347,7 @@ class Store implements StoreInterface
{
$path = $this->getPath($key);
return file_exists($path) && false !== ($contents = file_get_contents($path)) ? $contents : null;
return is_file($path) && false !== ($contents = file_get_contents($path)) ? $contents : null;
}
/**
@@ -374,7 +372,7 @@ class Store implements StoreInterface
return false;
}
} else {
if (!file_exists(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
if (!is_dir(\dirname($path)) && false === @mkdir(\dirname($path), 0777, true) && !is_dir(\dirname($path))) {
return false;
}
@@ -405,7 +403,7 @@ class Store implements StoreInterface
return true;
}
public function getPath($key)
public function getPath(string $key)
{
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);
}

View File

@@ -70,11 +70,9 @@ interface StoreInterface
/**
* Purges data for the given URL.
*
* @param string $url A URL
*
* @return bool true if the URL exists and has been purged, false otherwise
*/
public function purge($url);
public function purge(string $url);
/**
* Cleanups storage.

View File

@@ -23,7 +23,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
*/
class SubRequestHandler
{
public static function handle(HttpKernelInterface $kernel, Request $request, $type, $catch): Response
public static function handle(HttpKernelInterface $kernel, Request $request, int $type, bool $catch): Response
{
// save global state related to trusted headers and proxies
$trustedProxies = Request::getTrustedProxies();

View File

@@ -59,14 +59,12 @@ interface SurrogateInterface
/**
* Renders a Surrogate tag.
*
* @param string $uri A URI
* @param string $alt An alternate URI
* @param bool $ignoreErrors Whether to ignore errors or not
* @param string $comment A comment to add as an esi:include tag
* @param string $alt An alternate URI
* @param string $comment A comment to add as an esi:include tag
*
* @return string
*/
public function renderIncludeTag($uri, $alt = null, $ignoreErrors = true, $comment = '');
public function renderIncludeTag(string $uri, string $alt = null, bool $ignoreErrors = true, string $comment = '');
/**
* Replaces a Response Surrogate tags with the included resource content.
@@ -78,14 +76,12 @@ interface SurrogateInterface
/**
* Handles a Surrogate from the cache.
*
* @param string $uri The main URI
* @param string $alt An alternative URI
* @param bool $ignoreErrors Whether to ignore errors or not
* @param string $alt An alternative URI
*
* @return string
*
* @throws \RuntimeException
* @throws \Exception
*/
public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors);
public function handle(HttpCache $cache, string $uri, string $alt, bool $ignoreErrors);
}