1111
1212namespace Symfony \Component \Mailer ;
1313
14+ use Psr \EventDispatcher \EventDispatcherInterface ;
1415use Psr \Log \LoggerInterface ;
1516use Symfony \Component \Mailer \Bridge \Amazon \Transport \SesTransportFactory ;
1617use Symfony \Component \Mailer \Bridge \Google \Transport \GmailTransportFactory ;
3233use Symfony \Component \Mailer \Transport \TransportFactoryInterface ;
3334use Symfony \Component \Mailer \Transport \TransportInterface ;
3435use Symfony \Component \Mailer \Transport \Transports ;
35- use Symfony \Contracts \EventDispatcher \EventDispatcherInterface ;
3636use Symfony \Contracts \HttpClient \HttpClientInterface ;
3737
3838/**
3939 * @author Fabien Potencier <fabien@symfony.com>
4040 * @author Konstantin Myakshin <molodchick@gmail.com>
41+ *
42+ * @final since Symfony 5.4
4143 */
4244class Transport
4345{
@@ -54,15 +56,33 @@ class Transport
5456
5557 private $ factories ;
5658
57- public static function fromDsn (string $ dsn , EventDispatcherInterface $ dispatcher = null , HttpClientInterface $ client = null , LoggerInterface $ logger = null ): TransportInterface
59+ /**
60+ * @param EventDispatcherInterface|null $dispatcher
61+ * @param HttpClientInterface|null $client
62+ * @param LoggerInterface|null $logger
63+ */
64+ public static function fromDsn (string $ dsn/*, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null, LoggerInterface $logger = null*/ ): TransportInterface
5865 {
66+ $ dispatcher = 2 <= \func_num_args () ? func_get_arg (1 ) : null ;
67+ $ client = 3 <= \func_num_args () ? func_get_arg (2 ) : null ;
68+ $ logger = 4 <= \func_num_args () ? func_get_arg (3 ) : null ;
69+
5970 $ factory = new self (iterator_to_array (self ::getDefaultFactories ($ dispatcher , $ client , $ logger )));
6071
6172 return $ factory ->fromString ($ dsn );
6273 }
6374
64- public static function fromDsns (array $ dsns , EventDispatcherInterface $ dispatcher = null , HttpClientInterface $ client = null , LoggerInterface $ logger = null ): TransportInterface
75+ /**
76+ * @param EventDispatcherInterface|null $dispatcher
77+ * @param HttpClientInterface|null $client
78+ * @param LoggerInterface|null $logger
79+ */
80+ public static function fromDsns (array $ dsns/*, EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null, LoggerInterface $logger = null*/ ): TransportInterface
6581 {
82+ $ dispatcher = 2 <= \func_num_args () ? func_get_arg (1 ) : null ;
83+ $ client = 3 <= \func_num_args () ? func_get_arg (2 ) : null ;
84+ $ logger = 4 <= \func_num_args () ? func_get_arg (3 ) : null ;
85+
6686 $ factory = new self (iterator_to_array (self ::getDefaultFactories ($ dispatcher , $ client , $ logger )));
6787
6888 return $ factory ->fromStrings ($ dsns );
@@ -154,8 +174,19 @@ public function fromDsnObject(Dsn $dsn): TransportInterface
154174 throw new UnsupportedSchemeException ($ dsn );
155175 }
156176
157- public static function getDefaultFactories (EventDispatcherInterface $ dispatcher = null , HttpClientInterface $ client = null , LoggerInterface $ logger = null ): iterable
177+ /**
178+ * @param EventDispatcherInterface|null $dispatcher
179+ * @param HttpClientInterface|null $client
180+ * @param LoggerInterface|null $logger
181+ *
182+ * @return \Traversable<int, TransportFactoryInterface>
183+ */
184+ public static function getDefaultFactories (/*EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null, LoggerInterface $logger = null*/ ): iterable
158185 {
186+ $ dispatcher = 1 <= \func_num_args () ? func_get_arg (0 ) : null ;
187+ $ client = 2 <= \func_num_args () ? func_get_arg (1 ) : null ;
188+ $ logger = 3 <= \func_num_args () ? func_get_arg (2 ) : null ;
189+
159190 foreach (self ::FACTORY_CLASSES as $ factoryClass ) {
160191 if (class_exists ($ factoryClass )) {
161192 yield new $ factoryClass ($ dispatcher , $ client , $ logger );
0 commit comments