mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-21 16:22:20 +02:00
migration symfony 5 4 (#300)
* symfony 5.4 (diff dev) * symfony 5.4 (working) * symfony 5.4 (update autoload) * symfony 5.4 (remove swiftmailer mailer implementation) * symfony 5.4 (php doc and split Global accessor class) ### Impacted packages: composer require php:">=7.2.5 <8.0.0" symfony/console:5.4.* symfony/dotenv:5.4.* symfony/framework-bundle:5.4.* symfony/twig-bundle:5.4.* symfony/yaml:5.4.* --update-with-dependencies composer require symfony/stopwatch:5.4.* symfony/web-profiler-bundle:5.4.* --dev --update-with-dependencies
This commit is contained in:
@@ -47,20 +47,18 @@ class Section
|
||||
* @param float|null $origin Set the origin of the events in this section, use null to set their origin to their start time
|
||||
* @param bool $morePrecision If true, time is stored as float to keep the original microsecond precision
|
||||
*/
|
||||
public function __construct($origin = null, $morePrecision = false)
|
||||
public function __construct(float $origin = null, bool $morePrecision = false)
|
||||
{
|
||||
$this->origin = is_numeric($origin) ? $origin : null;
|
||||
$this->origin = $origin;
|
||||
$this->morePrecision = $morePrecision;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the child section.
|
||||
*
|
||||
* @param string $id The child section identifier
|
||||
*
|
||||
* @return self|null The child section or null when none found
|
||||
* @return self|null
|
||||
*/
|
||||
public function get($id)
|
||||
public function get(string $id)
|
||||
{
|
||||
foreach ($this->children as $child) {
|
||||
if ($id === $child->getId()) {
|
||||
@@ -78,9 +76,9 @@ class Section
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function open($id)
|
||||
public function open(?string $id)
|
||||
{
|
||||
if (null === $session = $this->get($id)) {
|
||||
if (null === $id || null === $session = $this->get($id)) {
|
||||
$session = $this->children[] = new self(microtime(true) * 1000, $this->morePrecision);
|
||||
}
|
||||
|
||||
@@ -88,7 +86,7 @@ class Section
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string The identifier of the section
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
@@ -98,11 +96,9 @@ class Section
|
||||
/**
|
||||
* Sets the session identifier.
|
||||
*
|
||||
* @param string $id The session identifier
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
public function setId(string $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
@@ -112,15 +108,12 @@ class Section
|
||||
/**
|
||||
* Starts an event.
|
||||
*
|
||||
* @param string $name The event name
|
||||
* @param string|null $category The event category
|
||||
*
|
||||
* @return StopwatchEvent The event
|
||||
* @return StopwatchEvent
|
||||
*/
|
||||
public function startEvent($name, $category)
|
||||
public function startEvent(string $name, ?string $category)
|
||||
{
|
||||
if (!isset($this->events[$name])) {
|
||||
$this->events[$name] = new StopwatchEvent($this->origin ?: microtime(true) * 1000, $category, $this->morePrecision);
|
||||
$this->events[$name] = new StopwatchEvent($this->origin ?: microtime(true) * 1000, $category, $this->morePrecision, $name);
|
||||
}
|
||||
|
||||
return $this->events[$name]->start();
|
||||
@@ -129,11 +122,9 @@ class Section
|
||||
/**
|
||||
* Checks if the event was started.
|
||||
*
|
||||
* @param string $name The event name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEventStarted($name)
|
||||
public function isEventStarted(string $name)
|
||||
{
|
||||
return isset($this->events[$name]) && $this->events[$name]->isStarted();
|
||||
}
|
||||
@@ -141,13 +132,11 @@ class Section
|
||||
/**
|
||||
* Stops an event.
|
||||
*
|
||||
* @param string $name The event name
|
||||
*
|
||||
* @return StopwatchEvent The event
|
||||
* @return StopwatchEvent
|
||||
*
|
||||
* @throws \LogicException When the event has not been started
|
||||
*/
|
||||
public function stopEvent($name)
|
||||
public function stopEvent(string $name)
|
||||
{
|
||||
if (!isset($this->events[$name])) {
|
||||
throw new \LogicException(sprintf('Event "%s" is not started.', $name));
|
||||
@@ -159,13 +148,11 @@ class Section
|
||||
/**
|
||||
* Stops then restarts an event.
|
||||
*
|
||||
* @param string $name The event name
|
||||
*
|
||||
* @return StopwatchEvent The event
|
||||
* @return StopwatchEvent
|
||||
*
|
||||
* @throws \LogicException When the event has not been started
|
||||
*/
|
||||
public function lap($name)
|
||||
public function lap(string $name)
|
||||
{
|
||||
return $this->stopEvent($name)->start();
|
||||
}
|
||||
@@ -173,13 +160,11 @@ class Section
|
||||
/**
|
||||
* Returns a specific event by name.
|
||||
*
|
||||
* @param string $name The event name
|
||||
*
|
||||
* @return StopwatchEvent The event
|
||||
* @return StopwatchEvent
|
||||
*
|
||||
* @throws \LogicException When the event is not known
|
||||
*/
|
||||
public function getEvent($name)
|
||||
public function getEvent(string $name)
|
||||
{
|
||||
if (!isset($this->events[$name])) {
|
||||
throw new \LogicException(sprintf('Event "%s" is not known.', $name));
|
||||
@@ -191,7 +176,7 @@ class Section
|
||||
/**
|
||||
* Returns the events from this section.
|
||||
*
|
||||
* @return StopwatchEvent[] An array of StopwatchEvent instances
|
||||
* @return StopwatchEvent[]
|
||||
*/
|
||||
public function getEvents()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user