N°8834 - Add compatibility with PHP 8.4 (#819)

* N°8834 - Add compatibility with PHP 8.4

* Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
Lenaick
2026-02-26 10:36:32 +01:00
committed by GitHub
parent d4821b7edc
commit fc967c06ce
961 changed files with 12298 additions and 7130 deletions

View File

@@ -36,7 +36,7 @@ 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(float $origin = null, bool $morePrecision = false)
public function __construct(?float $origin = null, bool $morePrecision = false)
{
$this->origin = $origin;
$this->morePrecision = $morePrecision;
@@ -115,7 +115,7 @@ class Section
public function stopEvent(string $name): StopwatchEvent
{
if (!isset($this->events[$name])) {
throw new \LogicException(sprintf('Event "%s" is not started.', $name));
throw new \LogicException(\sprintf('Event "%s" is not started.', $name));
}
return $this->events[$name]->stop();
@@ -139,7 +139,7 @@ class Section
public function getEvent(string $name): StopwatchEvent
{
if (!isset($this->events[$name])) {
throw new \LogicException(sprintf('Event "%s" is not known.', $name));
throw new \LogicException(\sprintf('Event "%s" is not known.', $name));
}
return $this->events[$name];

View File

@@ -61,12 +61,12 @@ class Stopwatch implements ResetInterface
*
* @throws \LogicException When the section to re-open is not reachable
*/
public function openSection(string $id = null)
public function openSection(?string $id = null)
{
$current = end($this->activeSections);
if (null !== $id && null === $current->get($id)) {
throw new \LogicException(sprintf('The section "%s" has been started at an other level and cannot be opened.', $id));
throw new \LogicException(\sprintf('The section "%s" has been started at an other level and cannot be opened.', $id));
}
$this->start('__section__.child', 'section');
@@ -100,7 +100,7 @@ class Stopwatch implements ResetInterface
/**
* Starts an event.
*/
public function start(string $name, string $category = null): StopwatchEvent
public function start(string $name, ?string $category = null): StopwatchEvent
{
return end($this->activeSections)->startEvent($name, $category);
}

View File

@@ -39,10 +39,8 @@ class StopwatchEvent
* @param string|null $category The event category or null to use the default
* @param bool $morePrecision If true, time is stored as float to keep the original microsecond precision
* @param string|null $name The event name or null to define the name as default
*
* @throws \InvalidArgumentException When the raw time is not valid
*/
public function __construct(float $origin, string $category = null, bool $morePrecision = false, string $name = null)
public function __construct(float $origin, ?string $category = null, bool $morePrecision = false, ?string $name = null)
{
$this->origin = $this->formatTime($origin);
$this->category = \is_string($category) ? $category : 'default';
@@ -207,8 +205,6 @@ class StopwatchEvent
/**
* Formats a time.
*
* @throws \InvalidArgumentException When the raw time is not valid
*/
private function formatTime(float $time): float
{
@@ -225,6 +221,6 @@ class StopwatchEvent
public function __toString(): string
{
return sprintf('%s/%s: %.2F MiB - %d ms', $this->getCategory(), $this->getName(), $this->getMemory() / 1024 / 1024, $this->getDuration());
return \sprintf('%s/%s: %.2F MiB - %d ms', $this->getCategory(), $this->getName(), $this->getMemory() / 1024 / 1024, $this->getDuration());
}
}

View File

@@ -68,6 +68,6 @@ class StopwatchPeriod
public function __toString(): string
{
return sprintf('%.2F MiB - %d ms', $this->getMemory() / 1024 / 1024, $this->getDuration());
return \sprintf('%.2F MiB - %d ms', $this->getMemory() / 1024 / 1024, $this->getDuration());
}
}