upgrade to laravel 7 and set branch to v2
This commit is contained in:
@@ -47,7 +47,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null, $statusCode = null): array
|
||||
public function find(?string $ip, ?string $url, ?int $limit, ?string $method, int $start = null, int $end = null, string $statusCode = null): array
|
||||
{
|
||||
$file = $this->getIndexFilename();
|
||||
|
||||
@@ -113,7 +113,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($token): ?Profile
|
||||
public function read(string $token): ?Profile
|
||||
{
|
||||
if (!$token || !file_exists($file = $this->getFilename($token))) {
|
||||
return null;
|
||||
@@ -200,11 +200,9 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
/**
|
||||
* Gets filename to store data, associated to the token.
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
* @return string The profile filename
|
||||
*/
|
||||
protected function getFilename($token)
|
||||
protected function getFilename(string $token)
|
||||
{
|
||||
// Uses 4 last characters, because first are mostly the same.
|
||||
$folderA = substr($token, -2, 2);
|
||||
@@ -270,7 +268,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
|
||||
return '' === $line ? null : $line;
|
||||
}
|
||||
|
||||
protected function createProfileFromData($token, $data, $parent = null)
|
||||
protected function createProfileFromData(string $token, array $data, Profile $parent = null)
|
||||
{
|
||||
$profile = new Profile($token);
|
||||
$profile->setIp($data['ip']);
|
||||
|
||||
43
vendor/symfony/http-kernel/Profiler/Profile.php
vendored
43
vendor/symfony/http-kernel/Profiler/Profile.php
vendored
@@ -48,12 +48,7 @@ class Profile
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the token.
|
||||
*
|
||||
* @param string $token The token
|
||||
*/
|
||||
public function setToken($token)
|
||||
public function setToken(string $token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
@@ -106,12 +101,7 @@ class Profile
|
||||
return $this->ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IP.
|
||||
*
|
||||
* @param string $ip
|
||||
*/
|
||||
public function setIp($ip)
|
||||
public function setIp(?string $ip)
|
||||
{
|
||||
$this->ip = $ip;
|
||||
}
|
||||
@@ -126,7 +116,7 @@ class Profile
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
public function setMethod($method)
|
||||
public function setMethod(string $method)
|
||||
{
|
||||
$this->method = $method;
|
||||
}
|
||||
@@ -141,17 +131,12 @@ class Profile
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*/
|
||||
public function setUrl($url)
|
||||
public function setUrl(?string $url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time.
|
||||
*
|
||||
* @return int The time
|
||||
*/
|
||||
public function getTime()
|
||||
@@ -163,18 +148,12 @@ class Profile
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $time The time
|
||||
*/
|
||||
public function setTime($time)
|
||||
public function setTime(int $time)
|
||||
{
|
||||
$this->time = $time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $statusCode
|
||||
*/
|
||||
public function setStatusCode($statusCode)
|
||||
public function setStatusCode(int $statusCode)
|
||||
{
|
||||
$this->statusCode = $statusCode;
|
||||
}
|
||||
@@ -233,13 +212,11 @@ class Profile
|
||||
/**
|
||||
* Gets a Collector by name.
|
||||
*
|
||||
* @param string $name A collector name
|
||||
*
|
||||
* @return DataCollectorInterface A DataCollectorInterface instance
|
||||
*
|
||||
* @throws \InvalidArgumentException if the collector does not exist
|
||||
*/
|
||||
public function getCollector($name)
|
||||
public function getCollector(string $name)
|
||||
{
|
||||
if (!isset($this->collectors[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name));
|
||||
@@ -280,13 +257,9 @@ class Profile
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a Collector for the given name exists.
|
||||
*
|
||||
* @param string $name A collector name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasCollector($name)
|
||||
public function hasCollector(string $name)
|
||||
{
|
||||
return isset($this->collectors[$name]);
|
||||
}
|
||||
|
||||
34
vendor/symfony/http-kernel/Profiler/Profiler.php
vendored
34
vendor/symfony/http-kernel/Profiler/Profiler.php
vendored
@@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\HttpKernel\Profiler;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -78,11 +77,9 @@ class Profiler implements ResetInterface
|
||||
/**
|
||||
* Loads the Profile for the given token.
|
||||
*
|
||||
* @param string $token A token
|
||||
*
|
||||
* @return Profile|null A Profile instance
|
||||
*/
|
||||
public function loadProfile($token)
|
||||
public function loadProfile(string $token)
|
||||
{
|
||||
return $this->storage->read($token);
|
||||
}
|
||||
@@ -119,19 +116,15 @@ class Profiler implements ResetInterface
|
||||
/**
|
||||
* Finds profiler tokens for the given criteria.
|
||||
*
|
||||
* @param string $ip The IP
|
||||
* @param string $url The URL
|
||||
* @param string $limit The maximum number of tokens to return
|
||||
* @param string $method The request method
|
||||
* @param string $start The start date to search from
|
||||
* @param string $end The end date to search to
|
||||
* @param string $statusCode The request status code
|
||||
* @param string|null $limit The maximum number of tokens to return
|
||||
* @param string|null $start The start date to search from
|
||||
* @param string|null $end The end date to search to
|
||||
*
|
||||
* @return array An array of tokens
|
||||
*
|
||||
* @see https://php.net/datetime.formats for the supported date/time formats
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start, $end, $statusCode = null)
|
||||
public function find(?string $ip, ?string $url, ?string $limit, ?string $method, ?string $start, ?string $end, string $statusCode = null)
|
||||
{
|
||||
return $this->storage->find($ip, $url, $limit, $method, $this->getTimestamp($start), $this->getTimestamp($end), $statusCode);
|
||||
}
|
||||
@@ -139,14 +132,10 @@ class Profiler implements ResetInterface
|
||||
/**
|
||||
* Collects data for the given Response.
|
||||
*
|
||||
* @param \Throwable|null $exception
|
||||
*
|
||||
* @return Profile|null A Profile instance or null if the profiler is disabled
|
||||
*/
|
||||
public function collect(Request $request, Response $response/*, \Throwable $exception = null*/)
|
||||
public function collect(Request $request, Response $response, \Throwable $exception = null)
|
||||
{
|
||||
$exception = 2 < \func_num_args() ? func_get_arg(2) : null;
|
||||
|
||||
if (false === $this->enabled) {
|
||||
return null;
|
||||
}
|
||||
@@ -168,14 +157,9 @@ class Profiler implements ResetInterface
|
||||
|
||||
$response->headers->set('X-Debug-Token', $profile->getToken());
|
||||
|
||||
$wrappedException = null;
|
||||
foreach ($this->collectors as $collector) {
|
||||
if (($e = $exception) instanceof \Error) {
|
||||
$r = new \ReflectionMethod($collector, 'collect');
|
||||
$e = 2 >= $r->getNumberOfParameters() || !($p = $r->getParameters()[2])->hasType() || \Exception::class !== $p->getType()->getName() ? $e : ($wrappedException ?? $wrappedException = new FatalThrowableError($e));
|
||||
}
|
||||
$collector->collect($request, $response, $exception);
|
||||
|
||||
$collector->collect($request, $response, $e);
|
||||
// we need to clone for sub-requests
|
||||
$profile->addCollector(clone $collector);
|
||||
}
|
||||
@@ -229,7 +213,7 @@ class Profiler implements ResetInterface
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function has($name)
|
||||
public function has(string $name)
|
||||
{
|
||||
return isset($this->collectors[$name]);
|
||||
}
|
||||
@@ -243,7 +227,7 @@ class Profiler implements ResetInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException if the collector does not exist
|
||||
*/
|
||||
public function get($name)
|
||||
public function get(string $name)
|
||||
{
|
||||
if (!isset($this->collectors[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name));
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Symfony\Component\HttpKernel\Profiler;
|
||||
* As the profiler must only be used on non-production servers, the file storage
|
||||
* is more than enough and no other implementations will ever be supported.
|
||||
*
|
||||
* @internal since 4.2
|
||||
* @internal
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
@@ -29,27 +29,22 @@ interface ProfilerStorageInterface
|
||||
/**
|
||||
* Finds profiler tokens for the given criteria.
|
||||
*
|
||||
* @param string $ip The IP
|
||||
* @param string $url The URL
|
||||
* @param string $limit The maximum number of tokens to return
|
||||
* @param string $method The request method
|
||||
* @param int|null $start The start date to search from
|
||||
* @param int|null $end The end date to search to
|
||||
* @param int|null $limit The maximum number of tokens to return
|
||||
* @param int|null $start The start date to search from
|
||||
* @param int|null $end The end date to search to
|
||||
*
|
||||
* @return array An array of tokens
|
||||
*/
|
||||
public function find($ip, $url, $limit, $method, $start = null, $end = null): array;
|
||||
public function find(?string $ip, ?string $url, ?int $limit, ?string $method, int $start = null, int $end = null): array;
|
||||
|
||||
/**
|
||||
* Reads data associated with the given token.
|
||||
*
|
||||
* The method returns false if the token does not exist in the storage.
|
||||
*
|
||||
* @param string $token A token
|
||||
*
|
||||
* @return Profile|null The profile associated with token
|
||||
*/
|
||||
public function read($token): ?Profile;
|
||||
public function read(string $token): ?Profile;
|
||||
|
||||
/**
|
||||
* Saves a Profile.
|
||||
|
||||
Reference in New Issue
Block a user