@@ -274,7 +274,7 @@ public static function connection($adapter = null, $name = null)
274
274
/**
275
275
* Opens a new connection and saves it to Doctrine_Manager->connections
276
276
*
277
- * @param PDO|Doctrine_Adapter_Interface $adapter database driver
277
+ * @param array|string| PDO|Doctrine_Adapter_Interface $adapter database driver
278
278
* @param string $name name of the connection, if empty numeric key is used
279
279
* @throws Doctrine_Manager_Exception if trying to bind a connection with an existing name
280
280
* @throws Doctrine_Manager_Exception if trying to open connection for unknown driver
@@ -292,17 +292,17 @@ public function openConnection($adapter, $name = null, $setCurrent = true)
292
292
if ( ! isset ($ adapter [0 ])) {
293
293
throw new Doctrine_Manager_Exception ('Empty data source name given. ' );
294
294
}
295
- $ e = explode (': ' , $ adapter [0 ]);
295
+ $ schema = explode (': ' , $ adapter [0 ]);
296
296
297
- if ($ e [0 ] == 'uri ' ) {
298
- $ e [0 ] = 'odbc ' ;
297
+ if ($ schema [0 ] = == 'uri ' ) {
298
+ $ schema [0 ] = 'odbc ' ;
299
299
}
300
300
301
301
$ parts ['dsn ' ] = $ adapter [0 ];
302
- $ parts ['scheme ' ] = $ e [0 ];
303
- $ parts ['user ' ] = ( isset ( $ adapter [1 ])) ? $ adapter [ 1 ] : null ;
304
- $ parts ['pass ' ] = ( isset ( $ adapter [2 ])) ? $ adapter [ 2 ] : null ;
305
- $ driverName = $ e [0 ];
302
+ $ parts ['scheme ' ] = $ schema [0 ];
303
+ $ parts ['user ' ] = $ adapter [1 ] ?? null ;
304
+ $ parts ['pass ' ] = $ adapter [2 ] ?? null ;
305
+ $ driverName = $ schema [0 ];
306
306
$ adapter = $ parts ;
307
307
} else {
308
308
$ parts = $ this ->parseDsn ($ adapter );
@@ -329,7 +329,7 @@ public function openConnection($adapter, $name = null, $setCurrent = true)
329
329
return $ this ->_connections [$ name ];
330
330
}
331
331
} else {
332
- $ name = $ this ->_index ;
332
+ $ name = ( string ) $ this ->_index ;
333
333
$ this ->_index ++;
334
334
}
335
335
@@ -352,11 +352,23 @@ public function openConnection($adapter, $name = null, $setCurrent = true)
352
352
/**
353
353
* Parse a pdo style dsn in to an array of parts
354
354
*
355
- * @param array $dsn An array of dsn information
356
- * @return array The array parsed
355
+ * @param string $dsn An array of dsn information
356
+ * @return array{
357
+ * dsn: string,
358
+ * scheme: string,
359
+ * host: ?string,
360
+ * user: ?string,
361
+ * pass: ?string,
362
+ * password: ?string,
363
+ * port: ?string,
364
+ * path: ?string,
365
+ * query: ?string,
366
+ * fragment: ?string,
367
+ * unix_socket: ?string,
368
+ * }
357
369
* @todo package:dbal
358
370
*/
359
- public function parsePdoDsn ($ dsn )
371
+ public function parsePdoDsn ($ dsn ): array
360
372
{
361
373
$ parts = array ();
362
374
@@ -401,7 +413,7 @@ public function parsePdoDsn($dsn)
401
413
* @param string $dsn
402
414
* @return array $parts
403
415
*/
404
- protected function _buildDsnPartsArray ($ dsn )
416
+ protected function _buildDsnPartsArray (string $ dsn )
405
417
{
406
418
// fix sqlite dsn so that it will parse correctly
407
419
$ dsn = str_replace ("//// " , "/ " , $ dsn );
@@ -437,7 +449,7 @@ protected function _buildDsnPartsArray($dsn)
437
449
* @return array Parsed contents of DSN
438
450
* @todo package:dbal
439
451
*/
440
- public function parseDsn ($ dsn )
452
+ public function parseDsn (string $ dsn )
441
453
{
442
454
$ parts = $ this ->_buildDsnPartsArray ($ dsn );
443
455
0 commit comments