diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index a7312d28e312..abf374dfa04d 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -477,6 +477,11 @@ Serializer * The `AbstractNormalizer::handleCircularReference()` method has two new `$format` and `$context` arguments. * Removed support for instantiating a `DataUriNormalizer` with a default MIME type guesser when the `symfony/mime` component isn't installed. +Stopwatch +--------- + + * Removed support for passing `null` as 1st (`$id`) argument of `Section::get()` method, pass a valid child section identifier instead. + Translation ----------- diff --git a/src/Symfony/Component/Stopwatch/CHANGELOG.md b/src/Symfony/Component/Stopwatch/CHANGELOG.md index 85a62f018119..14b7dc6dd5ef 100644 --- a/src/Symfony/Component/Stopwatch/CHANGELOG.md +++ b/src/Symfony/Component/Stopwatch/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +5.0.0 +----- + + * Removed support for passing `null` as 1st (`$id`) argument of `Section::get()` method, pass a valid child section identifier instead. + 4.4.0 ----- diff --git a/src/Symfony/Component/Stopwatch/Section.php b/src/Symfony/Component/Stopwatch/Section.php index 1bd96bc1edcc..56ff76196e72 100644 --- a/src/Symfony/Component/Stopwatch/Section.php +++ b/src/Symfony/Component/Stopwatch/Section.php @@ -56,11 +56,9 @@ public function __construct(float $origin = null, bool $morePrecision = false) /** * Returns the child section. * - * @param string $id The child section identifier - * * @return self|null The child section or null when none found */ - public function get($id) + public function get(string $id) { foreach ($this->children as $child) { if ($id === $child->getId()) { @@ -78,7 +76,7 @@ public function get($id) * * @return self */ - public function open($id) + public function open(?string $id) { if (null === $id || null === $session = $this->get($id)) { $session = $this->children[] = new self(microtime(true) * 1000, $this->morePrecision); @@ -98,11 +96,9 @@ public function getId() /** * 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,12 +108,9 @@ public function setId($id) /** * Starts an event. * - * @param string $name The event name - * @param string|null $category The event category - * * @return StopwatchEvent The event */ - 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); @@ -129,11 +122,9 @@ public function startEvent($name, $category) /** * 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 @@ public function isEventStarted($name) /** * Stops an event. * - * @param string $name The event name - * * @return StopwatchEvent The event * * @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 @@ public function stopEvent($name) /** * Stops then restarts an event. * - * @param string $name The event name - * * @return StopwatchEvent The event * * @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 @@ public function lap($name) /** * Returns a specific event by name. * - * @param string $name The event name - * * @return StopwatchEvent The event * * @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)); diff --git a/src/Symfony/Component/Stopwatch/Stopwatch.php b/src/Symfony/Component/Stopwatch/Stopwatch.php index a9f8862f523f..9a3fe56d86e7 100644 --- a/src/Symfony/Component/Stopwatch/Stopwatch.php +++ b/src/Symfony/Component/Stopwatch/Stopwatch.php @@ -59,7 +59,7 @@ public function getSections() * * @throws \LogicException When the section to re-open is not reachable */ - public function openSection($id = null) + public function openSection(string $id = null) { $current = end($this->activeSections); @@ -79,11 +79,9 @@ public function openSection($id = null) * * @see getSectionEvents() * - * @param string $id The identifier of the section - * * @throws \LogicException When there's no started section to be stopped */ - public function stopSection($id) + public function stopSection(string $id) { $this->stop('__section__'); @@ -98,12 +96,9 @@ public function stopSection($id) /** * Starts an event. * - * @param string $name The event name - * @param string|null $category The event category - * * @return StopwatchEvent */ - public function start($name, $category = null) + public function start(string $name, string $category = null) { return end($this->activeSections)->startEvent($name, $category); } @@ -111,11 +106,9 @@ public function start($name, $category = null) /** * Checks if the event was started. * - * @param string $name The event name - * * @return bool */ - public function isStarted($name) + public function isStarted(string $name) { return end($this->activeSections)->isEventStarted($name); } @@ -123,11 +116,9 @@ public function isStarted($name) /** * Stops an event. * - * @param string $name The event name - * * @return StopwatchEvent */ - public function stop($name) + public function stop(string $name) { return end($this->activeSections)->stopEvent($name); } @@ -135,11 +126,9 @@ public function stop($name) /** * Stops then restarts an event. * - * @param string $name The event name - * * @return StopwatchEvent */ - public function lap($name) + public function lap(string $name) { return end($this->activeSections)->stopEvent($name)->start(); } @@ -147,11 +136,9 @@ public function lap($name) /** * Returns a specific event by name. * - * @param string $name The event name - * * @return StopwatchEvent */ - public function getEvent($name) + public function getEvent(string $name) { return end($this->activeSections)->getEvent($name); } @@ -159,11 +146,9 @@ public function getEvent($name) /** * Gets all events for a given section. * - * @param string $id A section identifier - * * @return StopwatchEvent[] */ - public function getSectionEvents($id) + public function getSectionEvents(string $id) { return isset($this->sections[$id]) ? $this->sections[$id]->getEvents() : []; }