File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
7
7
## [ Unreleased]
8
8
9
+ ## [ 4.1.1] - 2025-03-21
10
+
11
+ ## Fixed
12
+ - Inject NullLogger to LoggerAwareInterface services, when logger is not set to container
13
+
9
14
## [ 4.1.0] - 2025-03-15
10
15
11
16
### Fixed
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ public function createInstance($class): object
91
91
$ logger = $ logger ($ this );
92
92
}
93
93
} else {
94
- $ logger = $ this ->getService (LoggerInterface::class);
94
+ $ logger = $ this ->has (LoggerInterface::class) ? $ this -> getService (LoggerInterface::class) : new NullLogger ( );
95
95
}
96
96
97
97
$ instance ->setLogger ($ logger );
Original file line number Diff line number Diff line change @@ -228,6 +228,17 @@ public function testLoggerInjection()
228
228
$ this ->assertSame ($ logger , $ loggerAware ->getLogger ());
229
229
}
230
230
231
+ public function testLoggerInjectionWithoutSpecifiedDefaultLoggerImpl ()
232
+ {
233
+ $ injector = new Injector ();
234
+ $ injector ->enableLoggerAwareInjection (true );
235
+
236
+ /**@var LoggerAwareClass $loggerAware */
237
+ $ loggerAware = $ injector ->createInstance (LoggerAwareClass::class);
238
+
239
+ $ this ->assertInstanceOf (NullLogger::class, $ loggerAware ->getLogger ());
240
+ }
241
+
231
242
public function testLoggerMap ()
232
243
{
233
244
$ logger = new NullLogger ();
You can’t perform that action at this time.
0 commit comments