composer update

This commit is contained in:
2019-12-01 06:37:45 +00:00
parent fa199eef05
commit 3115ab75a5
3650 changed files with 72361 additions and 147137 deletions

View File

@@ -47,7 +47,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
/**
* {@inheritdoc}
*/
public function find($ip, $url, $limit, $method, $start = null, $end = null, $statusCode = null)
public function find($ip, $url, $limit, $method, $start = null, $end = null, $statusCode = null): array
{
$file = $this->getIndexFilename();
@@ -113,10 +113,14 @@ class FileProfilerStorage implements ProfilerStorageInterface
/**
* {@inheritdoc}
*/
public function read($token)
public function read($token): ?Profile
{
if (!$token || !file_exists($file = $this->getFilename($token))) {
return;
return null;
}
if (\function_exists('gzcompress')) {
$file = 'compress.zlib://'.$file;
}
return $this->createProfileFromData($token, unserialize(file_get_contents($file)));
@@ -127,7 +131,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
*
* @throws \RuntimeException
*/
public function write(Profile $profile)
public function write(Profile $profile): bool
{
$file = $this->getFilename($profile->getToken());
@@ -161,7 +165,14 @@ class FileProfilerStorage implements ProfilerStorageInterface
'status_code' => $profile->getStatusCode(),
];
if (false === file_put_contents($file, serialize($data))) {
$context = stream_context_create();
if (\function_exists('gzcompress')) {
$file = 'compress.zlib://'.$file;
stream_context_set_option($context, 'zlib', 'level', 3);
}
if (false === file_put_contents($file, serialize($data), 0, $context)) {
return false;
}
@@ -227,7 +238,7 @@ class FileProfilerStorage implements ProfilerStorageInterface
$position = ftell($file);
if (0 === $position) {
return;
return null;
}
while (true) {
@@ -282,6 +293,10 @@ class FileProfilerStorage implements ProfilerStorageInterface
continue;
}
if (\function_exists('gzcompress')) {
$file = 'compress.zlib://'.$file;
}
$profile->addChild($this->createProfileFromData($token, unserialize(file_get_contents($file)), $profile));
}

View File

@@ -99,7 +99,7 @@ class Profile
/**
* Returns the IP.
*
* @return string The IP
* @return string|null The IP
*/
public function getIp()
{
@@ -119,7 +119,7 @@ class Profile
/**
* Returns the request method.
*
* @return string The request method
* @return string|null The request method
*/
public function getMethod()
{
@@ -134,13 +134,16 @@ class Profile
/**
* Returns the URL.
*
* @return string The URL
* @return string|null The URL
*/
public function getUrl()
{
return $this->url;
}
/**
* @param string $url
*/
public function setUrl($url)
{
$this->url = $url;
@@ -177,7 +180,7 @@ class Profile
}
/**
* @return int
* @return int|null
*/
public function getStatusCode()
{
@@ -288,6 +291,9 @@ class Profile
return isset($this->collectors[$name]);
}
/**
* @return array
*/
public function __sleep()
{
return ['token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode'];

View File

@@ -12,6 +12,7 @@
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;
@@ -63,12 +64,12 @@ class Profiler implements ResetInterface
/**
* Loads the Profile for the given Response.
*
* @return Profile|false A Profile instance
* @return Profile|null A Profile instance
*/
public function loadProfileFromResponse(Response $response)
{
if (!$token = $response->headers->get('X-Debug-Token')) {
return false;
return null;
}
return $this->loadProfile($token);
@@ -79,7 +80,7 @@ class Profiler implements ResetInterface
*
* @param string $token A token
*
* @return Profile A Profile instance
* @return Profile|null A Profile instance
*/
public function loadProfile($token)
{
@@ -128,7 +129,7 @@ class Profiler implements ResetInterface
*
* @return array An array of tokens
*
* @see http://php.net/manual/en/datetime.formats.php for the supported date/time formats
* @see https://php.net/datetime.formats for the supported date/time formats
*/
public function find($ip, $url, $limit, $method, $start, $end, $statusCode = null)
{
@@ -138,12 +139,16 @@ 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, \Exception $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;
return null;
}
$profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
@@ -163,9 +168,14 @@ class Profiler implements ResetInterface
$response->headers->set('X-Debug-Token', $profile->getToken());
$wrappedException = null;
foreach ($this->collectors as $collector) {
$collector->collect($request, $response, $exception);
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, $e);
// we need to clone for sub-requests
$profile->addCollector(clone $collector);
}
@@ -242,16 +252,16 @@ class Profiler implements ResetInterface
return $this->collectors[$name];
}
private function getTimestamp($value)
private function getTimestamp(?string $value): ?int
{
if (null === $value || '' == $value) {
return;
if (null === $value || '' === $value) {
return null;
}
try {
$value = new \DateTime(is_numeric($value) ? '@'.$value : $value);
} catch (\Exception $e) {
return;
return null;
}
return $value->getTimestamp();

View File

@@ -38,7 +38,7 @@ interface ProfilerStorageInterface
*
* @return array An array of tokens
*/
public function find($ip, $url, $limit, $method, $start = null, $end = null);
public function find($ip, $url, $limit, $method, $start = null, $end = null): array;
/**
* Reads data associated with the given token.
@@ -47,16 +47,16 @@ interface ProfilerStorageInterface
*
* @param string $token A token
*
* @return Profile The profile associated with token
* @return Profile|null The profile associated with token
*/
public function read($token);
public function read($token): ?Profile;
/**
* Saves a Profile.
*
* @return bool Write operation successful
*/
public function write(Profile $profile);
public function write(Profile $profile): bool;
/**
* Purges all data from the database.