Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Collector/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ public function getStacks()
}

/**
* @return Stack|bool false if no current stack.
* @return Stack|null Return null there is no current stack.
*/
public function getCurrentStack()
{
return end($this->data['stacks']);
if (false === $stack = end($this->data['stacks'])) {
return null;
}

return $stack;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Collector/ProfileClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function sendRequest(RequestInterface $request)
*/
private function collectRequestInformations(RequestInterface $request, Stack $stack = null)
{
if (!$stack) {
if (null === $stack) {
return;
}

Expand All @@ -143,7 +143,7 @@ private function collectRequestInformations(RequestInterface $request, Stack $st
*/
private function collectResponseInformations(ResponseInterface $response, StopwatchEvent $event, Stack $stack = null)
{
if (!$stack) {
if (null === $stack) {
return;
}

Expand All @@ -163,7 +163,7 @@ private function collectExceptionInformations(\Exception $exception, StopwatchEv
$this->collectResponseInformations($exception->getResponse(), $event, $stack);
}

if (!$stack) {
if (null === $stack) {
return;
}

Expand Down
3 changes: 2 additions & 1 deletion Collector/ProfilePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
{
$profile = new Profile($this->pluginName, $this->formatter->formatRequest($request));

if ($stack = $this->collector->getCurrentStack()) {
$stack = $this->collector->getCurrentStack();
if (null !== $stack) {
$stack->addProfile($profile);
}

Expand Down