On the one hand, it's unclear to the implementors of Driver::connect(), whether the parameters should be taken from $params or from the individual parameters. On the other hand, the code components that call connect() need to mimic the behavior of the Connection class:
By being this verbose, this API doesn't solve any design problem. On the contrary, once a driver receives these parameters individually, it may have to pack them back or regroup otherwise before processing:
Since Driver::connect() plays the role of an adapter between the DBAL Connection::connect() and the Driver Connection::__construct(), it shouldn't expect Connection::connect() to do any adaptation.
User credentials and driver options are passed to the driver both via individual parameters and as part of
$params
: https://github.com/doctrine/dbal/blob/48625f1bc761f1f8f70fe6630a0f3a3204d9a6ff/src/Connection.php#L352-L356On the one hand, it's unclear to the implementors of
Driver::connect()
, whether the parameters should be taken from$params
or from the individual parameters. On the other hand, the code components that callconnect()
need to mimic the behavior of theConnection
class:More examples:
3. https://github.com/doctrine/dbal/blob/48625f1bc761f1f8f70fe6630a0f3a3204d9a6ff/tests/Functional/Schema/SchemaManagerFunctionalTestCase.php#L120-L123 4. https://github.com/doctrine/dbal/blob/48625f1bc761f1f8f70fe6630a0f3a3204d9a6ff/tests/Functional/Schema/SqliteSchemaManagerTest.php#L53-L56 5. https://github.com/doctrine/dbal/blob/f88dc282080826528fe7326cb9a7c465aa3074d7/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php#L63-L68 6. https://github.com/doctrine/dbal/blob/f88dc282080826528fe7326cb9a7c465aa3074d7/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php#L96-L101 7. https://github.com/doctrine/dbal/blob/f88dc282080826528fe7326cb9a7c465aa3074d7/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php#L47-L52By being this verbose, this API doesn't solve any design problem. On the contrary, once a driver receives these parameters individually, it may have to pack them back or regroup otherwise before processing:
Since
Driver::connect()
plays the role of an adapter between the DBALConnection::connect()
and the DriverConnection::__construct()
, it shouldn't expectConnection::connect()
to do any adaptation.