Beispiel #1
0
 public function testExtendedBindingsKeptTypes()
 {
     $container = new Container();
     $container->singleton(['foo' => 'foo2'], function () {
         return (object) ['name' => 'narrowspark'];
     });
     $container->extend('foo', function ($old, $container) {
         $old->oldName = 'viserio';
         return $old;
     });
     $container->bind('bar', function () {
         return (object) ['name' => 'narrowspark'];
     });
     $container->extend('bar', function ($old, $container) {
         $old->oldName = 'viserio';
         return $old;
     });
     $this->assertSame($container->make('foo'), $container->make('foo'));
     $this->assertSame($container->make('foo'), $container->make('foo2'));
     $this->assertNotSame($container->make('bar'), $container->make('bar'));
 }