diff --git a/docs/guide/concept-di-container.md b/docs/guide/concept-di-container.md index e58057cc9b..426abba60a 100644 --- a/docs/guide/concept-di-container.md +++ b/docs/guide/concept-di-container.md @@ -95,29 +95,25 @@ $container->set('Foo', function () { $foo = $container->get('Foo'); ``` -To hide the complex logic for building a new object, you may use a static class method to return the PHP -callable. For example, +To hide the complex logic for building a new object, you may use a static class method as callable. For example, ```php class FooBuilder { public static function build() { - return function () { - $foo = new Foo(new Bar); - // ... other initializations ... - return $foo; - }; + $foo = new Foo(new Bar); + // ... other initializations ... + return $foo; } } -$container->set('Foo', FooBuilder::build()); +$container->set('Foo', ['app\helper\FooBuilder', 'build']); $foo = $container->get('Foo'); ``` -As you can see, the PHP callable is returned by the `FooBuilder::build()` method. By doing so, the person -who wants to configure the `Foo` class no longer needs to be aware of how it is built. +By doing so, the person who wants to configure the `Foo` class no longer needs to be aware of how it is built. Registering Dependencies