File tree 2 files changed +7
-4
lines changed
src/Symfony/Bridge/Monolog
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -60,8 +60,8 @@ public function __invoke(array $record)
60
60
*/
61
61
public function getLogs (/* Request $request = null */ )
62
62
{
63
- if (1 <= \func_num_args () && null !== ( $ request = \func_get_arg (0 )) && isset ( $ this -> records [ $ hash = spl_object_hash ( $ request )] )) {
64
- return $ this ->records [$ hash ] ;
63
+ if (1 <= \func_num_args () && null !== $ request = \func_get_arg (0 )) {
64
+ return $ this ->records [spl_object_hash ( $ request )] ?? array () ;
65
65
}
66
66
67
67
if (0 === \count ($ this ->records )) {
@@ -76,8 +76,8 @@ public function getLogs(/* Request $request = null */)
76
76
*/
77
77
public function countErrors (/* Request $request = null */ )
78
78
{
79
- if (1 <= \func_num_args () && null !== ( $ request = \func_get_arg (0 )) && isset ( $ this -> errorCount [ $ hash = spl_object_hash ( $ request )] )) {
80
- return $ this ->errorCount [$ hash ] ;
79
+ if (1 <= \func_num_args () && null !== $ request = \func_get_arg (0 )) {
80
+ return $ this ->errorCount [spl_object_hash ( $ request )] ?? 0 ;
81
81
}
82
82
83
83
return array_sum ($ this ->errorCount );
Original file line number Diff line number Diff line change @@ -58,6 +58,9 @@ public function testWithRequestStack()
58
58
59
59
$ this ->assertCount (2 , $ processor ->getLogs ($ request ));
60
60
$ this ->assertSame (1 , $ processor ->countErrors ($ request ));
61
+
62
+ $ this ->assertCount (0 , $ processor ->getLogs (new Request ()));
63
+ $ this ->assertSame (0 , $ processor ->countErrors (new Request ()));
61
64
}
62
65
63
66
private function getRecord ($ level = Logger::WARNING , $ message = 'test ' )
You can’t perform that action at this time.
0 commit comments