@@ -228,6 +228,7 @@ public function testAttributeOnAppCall()
228
228
$ container ->singleton ('config ' , fn () => new Repository ([
229
229
'app ' => [
230
230
'timezone ' => 'Europe/Paris ' ,
231
+ 'locale ' => null ,
231
232
],
232
233
]));
233
234
@@ -236,6 +237,35 @@ public function testAttributeOnAppCall()
236
237
});
237
238
238
239
$ this ->assertEquals ('Europe/Paris ' , $ value );
240
+
241
+ $ value = $ container ->call (function (#[Config('app.locale ' )] ?string $ value ) {
242
+ return $ value ;
243
+ });
244
+
245
+ $ this ->assertNull ($ value );
246
+ }
247
+
248
+ public function testNestedAttributeOnAppCall ()
249
+ {
250
+ $ container = new Container ;
251
+ $ container ->singleton ('config ' , fn () => new Repository ([
252
+ 'app ' => [
253
+ 'timezone ' => 'Europe/Paris ' ,
254
+ 'locale ' => null ,
255
+ ],
256
+ ]));
257
+
258
+ $ value = $ container ->call (function (TimezoneObject $ object ) {
259
+ return $ object ;
260
+ });
261
+
262
+ $ this ->assertEquals ('Europe/Paris ' , $ value ->timezone );
263
+
264
+ $ value = $ container ->call (function (LocaleObject $ object ) {
265
+ return $ object ;
266
+ });
267
+
268
+ $ this ->assertNull ($ value ->locale );
239
269
}
240
270
241
271
public function testTagAttribute ()
@@ -404,3 +434,21 @@ public function __construct(#[Storage('foo')] Filesystem $foo, #[Storage('bar')]
404
434
{
405
435
}
406
436
}
437
+
438
+ final class TimezoneObject
439
+ {
440
+ public function __construct (
441
+ #[Config('app.timezone ' )] public readonly ?string $ timezone
442
+ ) {
443
+ //
444
+ }
445
+ }
446
+
447
+ final class LocaleObject
448
+ {
449
+ public function __construct (
450
+ #[Config('app.locale ' )] public readonly ?string $ locale
451
+ ) {
452
+ //
453
+ }
454
+ }
0 commit comments