Upgrade framework
This commit is contained in:
147
vendor/symfony/http-kernel/Profiler/Profile.php
vendored
147
vendor/symfony/http-kernel/Profiler/Profile.php
vendored
@@ -20,173 +20,122 @@ use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
|
||||
*/
|
||||
class Profile
|
||||
{
|
||||
private $token;
|
||||
private string $token;
|
||||
|
||||
/**
|
||||
* @var DataCollectorInterface[]
|
||||
*/
|
||||
private $collectors = array();
|
||||
private array $collectors = [];
|
||||
|
||||
private $ip;
|
||||
private $method;
|
||||
private $url;
|
||||
private $time;
|
||||
private $statusCode;
|
||||
|
||||
/**
|
||||
* @var Profile
|
||||
*/
|
||||
private $parent;
|
||||
private ?string $ip = null;
|
||||
private ?string $method = null;
|
||||
private ?string $url = null;
|
||||
private ?int $time = null;
|
||||
private ?int $statusCode = null;
|
||||
private ?self $parent = null;
|
||||
|
||||
/**
|
||||
* @var Profile[]
|
||||
*/
|
||||
private $children = array();
|
||||
private array $children = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $token The token
|
||||
*/
|
||||
public function __construct($token)
|
||||
public function __construct(string $token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the token.
|
||||
*
|
||||
* @param string $token The token
|
||||
*/
|
||||
public function setToken($token)
|
||||
public function setToken(string $token)
|
||||
{
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the token.
|
||||
*
|
||||
* @return string The token
|
||||
*/
|
||||
public function getToken()
|
||||
public function getToken(): string
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent token.
|
||||
*
|
||||
* @param Profile $parent
|
||||
*/
|
||||
public function setParent(Profile $parent)
|
||||
public function setParent(self $parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent profile.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function getParent()
|
||||
public function getParent(): ?self
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent token.
|
||||
*
|
||||
* @return null|string The parent token
|
||||
*/
|
||||
public function getParentToken()
|
||||
public function getParentToken(): ?string
|
||||
{
|
||||
return $this->parent ? $this->parent->getToken() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the IP.
|
||||
*
|
||||
* @return string The IP
|
||||
*/
|
||||
public function getIp()
|
||||
public function getIp(): ?string
|
||||
{
|
||||
return $this->ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the IP.
|
||||
*
|
||||
* @param string $ip
|
||||
*/
|
||||
public function setIp($ip)
|
||||
public function setIp(?string $ip)
|
||||
{
|
||||
$this->ip = $ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the request method.
|
||||
*
|
||||
* @return string The request method
|
||||
*/
|
||||
public function getMethod()
|
||||
public function getMethod(): ?string
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
public function setMethod($method)
|
||||
public function setMethod(string $method)
|
||||
{
|
||||
$this->method = $method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL.
|
||||
*
|
||||
* @return string The URL
|
||||
*/
|
||||
public function getUrl()
|
||||
public function getUrl(): ?string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function setUrl($url)
|
||||
public function setUrl(?string $url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time.
|
||||
*
|
||||
* @return int The time
|
||||
*/
|
||||
public function getTime()
|
||||
public function getTime(): int
|
||||
{
|
||||
if (null === $this->time) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->time;
|
||||
return $this->time ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
public function getStatusCode(): ?int
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
@@ -196,7 +145,7 @@ class Profile
|
||||
*
|
||||
* @return self[]
|
||||
*/
|
||||
public function getChildren()
|
||||
public function getChildren(): array
|
||||
{
|
||||
return $this->children;
|
||||
}
|
||||
@@ -208,7 +157,7 @@ class Profile
|
||||
*/
|
||||
public function setChildren(array $children)
|
||||
{
|
||||
$this->children = array();
|
||||
$this->children = [];
|
||||
foreach ($children as $child) {
|
||||
$this->addChild($child);
|
||||
}
|
||||
@@ -216,25 +165,30 @@ class Profile
|
||||
|
||||
/**
|
||||
* Adds the child token.
|
||||
*
|
||||
* @param Profile $child
|
||||
*/
|
||||
public function addChild(Profile $child)
|
||||
public function addChild(self $child)
|
||||
{
|
||||
$this->children[] = $child;
|
||||
$child->setParent($this);
|
||||
}
|
||||
|
||||
public function getChildByToken(string $token): ?self
|
||||
{
|
||||
foreach ($this->children as $child) {
|
||||
if ($token === $child->getToken()) {
|
||||
return $child;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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): DataCollectorInterface
|
||||
{
|
||||
if (!isset($this->collectors[$name])) {
|
||||
throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name));
|
||||
@@ -248,7 +202,7 @@ class Profile
|
||||
*
|
||||
* @return DataCollectorInterface[]
|
||||
*/
|
||||
public function getCollectors()
|
||||
public function getCollectors(): array
|
||||
{
|
||||
return $this->collectors;
|
||||
}
|
||||
@@ -260,7 +214,7 @@ class Profile
|
||||
*/
|
||||
public function setCollectors(array $collectors)
|
||||
{
|
||||
$this->collectors = array();
|
||||
$this->collectors = [];
|
||||
foreach ($collectors as $collector) {
|
||||
$this->addCollector($collector);
|
||||
}
|
||||
@@ -268,28 +222,19 @@ class Profile
|
||||
|
||||
/**
|
||||
* Adds a Collector.
|
||||
*
|
||||
* @param DataCollectorInterface $collector A DataCollectorInterface instance
|
||||
*/
|
||||
public function addCollector(DataCollectorInterface $collector)
|
||||
{
|
||||
$this->collectors[$collector->getName()] = $collector;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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): bool
|
||||
{
|
||||
return isset($this->collectors[$name]);
|
||||
}
|
||||
|
||||
public function __sleep()
|
||||
public function __sleep(): array
|
||||
{
|
||||
return array('token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode');
|
||||
return ['token', 'parent', 'children', 'collectors', 'ip', 'method', 'url', 'time', 'statusCode'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user