Skip to content

Commit

Permalink
[Stopwatch] Add null check for id argument in Section::open()
Browse files Browse the repository at this point in the history
  • Loading branch information
jschaedl committed Jul 8, 2019
1 parent cdfd615 commit 13f95a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions UPGRADE-5.0.md
Expand Up @@ -456,6 +456,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 of passing `null` as 1st (`$id`) argument of `Section::get()` method, pass a valid child section identifier instead.

Translation
-----------

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Stopwatch/Section.php
Expand Up @@ -58,7 +58,7 @@ public function __construct(float $origin = null, bool $morePrecision = false)
*
* @return self|null The child section or null when none found
*/
public function get(?string $id)
public function get(string $id)
{
if (null === $id) {
@trigger_error(sprintf('Passing "null" as the first argument of the "%s()" method is deprecated since Symfony 4.4, pass a valid child section identifier instead.', __METHOD__), E_USER_DEPRECATED);
Expand All @@ -80,7 +80,7 @@ public function get(?string $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);
}

Expand Down

0 comments on commit 13f95a6

Please sign in to comment.