File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -374,6 +374,30 @@ dealing with the ``TransformerInterface``.
374374 discovered that implements an interface, configuring the alias is not mandatory
375375 and Symfony will automatically create one.
376376
377+ .. tip ::
378+
379+ Autowiring is powerful enough to guess which service to inject even when using
380+ union and intersection types. This means you're able to type-hint argument with
381+ complex types like this::
382+
383+ use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
384+ use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
385+ use Symfony\Component\Serializer\SerializerInterface;
386+
387+ class DataFormatter
388+ {
389+ public function __construct((NormalizerInterface&DenormalizerInterface)|SerializerInterface $transformer)
390+ {
391+ // ...
392+ }
393+
394+ // ...
395+ }
396+
397+ .. versionadded :: 5.4
398+
399+ The support of union and intersection types was introduced in Symfony 5.4.
400+
377401Dealing with Multiple Implementations of the Same Type
378402------------------------------------------------------
379403
You can’t perform that action at this time.
0 commit comments