Skip to content

Commit f2817d0

Browse files
committed
Update documentation according to code
1 parent 4f5bec9 commit f2817d0

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

service_container/service_decoration.rst

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -382,38 +382,31 @@ Three different behaviors are available:
382382
* ``null``: When used, the container will keep the decorator
383383
service and will set the decorated one to `null`.
384384

385-
.. note::
386-
387-
If you are using yaml to describe your services, please ensure that
388-
``null`` value is wrapped with quotes. In fact in yaml, ``null`` will be interpreted
389-
as the null value and not as the null string. Therefore, the compiler will throw
390-
an ``InvalidArgumentException``
391-
392-
.. code-block:: yaml
393-
394-
Foo:
395-
decorates: Foo
396-
decoration_on_invalid: 'null'
397-
arguments: ['@Bar.inner']
398-
399385
.. tip::
400386

401387
When using ``null``, you may update the decorator's constructor in
402388
order to make decorated dependency nullable. In this way, you will be able to
403389
check the presence of decorated service in other methods.
404390

391+
.. code-block:: yaml
392+
393+
App\Service\DecoratorService:
394+
decorates: Acme\OptionalBundle\Service\OptionalService
395+
decoration_on_invalid: null
396+
arguments: ['@App\Service\DecoratorService.inner']
397+
405398
::
406399

407400
namespace App\Service;
408401

409-
use App\Service\OptionalDecoratedService;
402+
use Acme\OptionalBundle\Service\OptionalService;
410403

411404
class DecoratorService
412405
{
413406
private $decorated;
414407

415-
- public function __construct(OptionalDecoratedService $decorated)
416-
+ public function __construct(?OptionalDecoratedService $decorated)
408+
- public function __construct(OptionalService $decorated)
409+
+ public function __construct(?OptionalService $decorated)
417410
{
418411
$this->decorated = $decorated;
419412
}

0 commit comments

Comments
 (0)