[MonologBridge] Return empty list for unknonwn requests
This commit is contained in:
parent
b178266bcd
commit
69be8e649e
@ -60,8 +60,8 @@ class DebugProcessor implements DebugLoggerInterface
|
||||
*/
|
||||
public function getLogs(/* Request $request = null */)
|
||||
{
|
||||
if (1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) && isset($this->records[$hash = spl_object_hash($request)])) {
|
||||
return $this->records[$hash];
|
||||
if (1 <= \func_num_args() && null !== $request = \func_get_arg(0)) {
|
||||
return $this->records[spl_object_hash($request)] ?? array();
|
||||
}
|
||||
|
||||
if (0 === \count($this->records)) {
|
||||
@ -76,8 +76,8 @@ class DebugProcessor implements DebugLoggerInterface
|
||||
*/
|
||||
public function countErrors(/* Request $request = null */)
|
||||
{
|
||||
if (1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) && isset($this->errorCount[$hash = spl_object_hash($request)])) {
|
||||
return $this->errorCount[$hash];
|
||||
if (1 <= \func_num_args() && null !== $request = \func_get_arg(0)) {
|
||||
return $this->errorCount[spl_object_hash($request)] ?? 0;
|
||||
}
|
||||
|
||||
return array_sum($this->errorCount);
|
||||
|
@ -58,6 +58,9 @@ class DebugProcessorTest extends TestCase
|
||||
|
||||
$this->assertCount(2, $processor->getLogs($request));
|
||||
$this->assertSame(1, $processor->countErrors($request));
|
||||
|
||||
$this->assertCount(0, $processor->getLogs(new Request()));
|
||||
$this->assertSame(0, $processor->countErrors(new Request()));
|
||||
}
|
||||
|
||||
private function getRecord($level = Logger::WARNING, $message = 'test')
|
||||
|
Reference in New Issue
Block a user