diff --git a/Collector/Collector.php b/Collector/Collector.php index 60111434..15d61024 100644 --- a/Collector/Collector.php +++ b/Collector/Collector.php @@ -62,7 +62,7 @@ public function getStacks() } /** - * @return Stack + * @return Stack|bool false if no current stack. */ public function getCurrentStack() { diff --git a/Collector/ProfilePlugin.php b/Collector/ProfilePlugin.php index 4517f318..cf05afc5 100644 --- a/Collector/ProfilePlugin.php +++ b/Collector/ProfilePlugin.php @@ -58,7 +58,9 @@ public function handleRequest(RequestInterface $request, callable $next, callabl { $profile = new Profile($this->pluginName, $this->formatter->formatRequest($request)); - $this->collector->getCurrentStack()->addProfile($profile); + if ($stack = $this->collector->getCurrentStack()) { + $stack->addProfile($profile); + } return $this->plugin->handleRequest($request, $next, $first)->then(function (ResponseInterface $response) use ($profile) { $profile->setResponse($this->formatter->formatResponse($response));