Skip to content

Commit 91acbea

Browse files
committed
refactor Logs collector
1 parent c65b238 commit 91acbea

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

system/Debug/Toolbar/Collectors/Logs.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ class Logs extends BaseCollector
4545
/**
4646
* Our collected data.
4747
*
48-
* @var array
48+
* @var list<array{level: string, msg: string}>
4949
*/
5050
protected $data;
5151

5252
/**
53-
* Returns the data of this collector to be formatted in the toolbar
53+
* Returns the data of this collector to be formatted in the toolbar.
54+
*
55+
* @return array{logs: list<array{level: string, msg: string}>}
5456
*/
5557
public function display(): array
5658
{
@@ -66,7 +68,7 @@ public function isEmpty(): bool
6668
{
6769
$this->collectLogs();
6870

69-
return empty($this->data);
71+
return $this->data !== [];
7072
}
7173

7274
/**
@@ -82,14 +84,14 @@ public function icon(): string
8284
/**
8385
* Ensures the data has been collected.
8486
*
85-
* @return array
87+
* @return list<array{level: string, msg: string}>
8688
*/
8789
protected function collectLogs()
8890
{
89-
if (! empty($this->data)) {
91+
if ($this->data !== []) {
9092
return $this->data;
9193
}
9294

93-
return $this->data = service('logger', true)->logCache ?? [];
95+
return $this->data = service('logger', true)->logCache;
9496
}
9597
}

0 commit comments

Comments
 (0)