From 3b44f5594e943be32e53ce8ca79ae168be8559ca Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 2 Jul 2020 18:48:07 -0700 Subject: [PATCH 1/2] Mark connection constructors internal --- UPGRADE.md | 6 ++++-- lib/Doctrine/DBAL/Connection.php | 2 ++ lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php | 2 ++ .../DBAL/Connections/PrimaryReadReplicaConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php | 2 ++ lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php | 2 ++ lib/Doctrine/DBAL/Driver/PDOConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php | 2 ++ .../DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php | 2 ++ lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php | 2 ++ 12 files changed, 26 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index ad04122bd99..df5f752f7c4 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -19,9 +19,11 @@ The method is not used anywhere except for tests. The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been deprecated as an implementation detail which is the same for almost all supported drivers. -## Statement constructors are marked internal +## Connection and Statement constructors are marked internal -The driver and wrapper statement objects can be only created by the corresponding connection objects. +1. Driver connection objects can be only created by the corresponding drivers. +2. Wrapper connection objects can be only created by the driver manager. +3. The driver and wrapper connection objects can be only created by the corresponding connection objects. ## The `PingableConnection` interface is deprecated diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 33a38ab9dcc..29eda274608 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -168,6 +168,8 @@ class Connection implements DriverConnection /** * Initializes a new instance of the Connection class. * + * @internal The connection can be only instantiated by the driver manager. + * * @param mixed[] $params The connection parameters. * @param Driver $driver The driver to use. * @param Configuration|null $config The configuration, optional. diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index 39b0c6165d5..156753457d6 100644 --- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -20,6 +20,8 @@ class MasterSlaveConnection extends PrimaryReadReplicaConnection /** * Creates Primary Replica Connection. * + * @internal The connection can be only instantiated by the driver manager. + * * @param mixed[] $params * * @throws InvalidArgumentException diff --git a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php index cb78b69c451..86aad20d14b 100644 --- a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php +++ b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php @@ -90,6 +90,8 @@ class PrimaryReadReplicaConnection extends Connection /** * Creates Primary Replica Connection. * + * @internal The connection can be only instantiated by the driver manager. + * * @param mixed[] $params * * @throws InvalidArgumentException diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php index 655bbb39d4c..8beef436b2e 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -40,6 +40,8 @@ class DB2Connection implements ConnectionInterface, ServerInfoAwareConnection private $conn = null; /** + * @internal The connection can be only instantiated by its driver. + * * @param mixed[] $params * @param string $username * @param string $password diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 2e8dd185013..de009d4ed32 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -46,6 +46,8 @@ class MysqliConnection implements ConnectionInterface, PingableConnection, Serve private $conn; /** + * @internal The connection can be only instantiated by its driver. + * * @param mixed[] $params * @param string $username * @param string $password diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index 2ee1e365fc3..7a56b6e1a56 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -41,6 +41,8 @@ class OCI8Connection implements ConnectionInterface, ServerInfoAwareConnection /** * Creates a Connection to an Oracle Database using oci8 extension. * + * @internal The connection can be only instantiated by its driver. + * * @param string $username * @param string $password * @param string $db diff --git a/lib/Doctrine/DBAL/Driver/PDOConnection.php b/lib/Doctrine/DBAL/Driver/PDOConnection.php index 9e124e528bc..4f72e820b77 100644 --- a/lib/Doctrine/DBAL/Driver/PDOConnection.php +++ b/lib/Doctrine/DBAL/Driver/PDOConnection.php @@ -22,6 +22,8 @@ class PDOConnection extends PDO implements ConnectionInterface, ServerInfoAwareConnection { /** + * @internal The connection can be only instantiated by its driver. + * * @param string $dsn * @param string|null $user * @param string|null $password diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index 8e36d2f1501..d0262dcf6a7 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -17,6 +17,8 @@ class Connection extends BaseConnection { /** + * @internal The connection can be only instantiated by its driver. + * * {@inheritdoc} */ public function __construct($dsn, $user = null, $password = null, ?array $options = null) diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php index b56fd61ff2d..cee7447129d 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php @@ -36,6 +36,8 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection /** * Connects to database with given connection string. * + * @internal The connection can be only instantiated by its driver. + * * @param string $dsn The connection string. * @param bool $persistent Whether or not to establish a persistent connection. * diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index 10095cde411..de783309883 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -39,6 +39,8 @@ class SQLSrvConnection implements ConnectionInterface, ServerInfoAwareConnection protected $lastInsertId; /** + * @internal The connection can be only instantiated by its driver. + * * @param string $serverName * @param mixed[] $connectionOptions * diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php index 8c20139ac42..db81e381c85 100644 --- a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php +++ b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php @@ -65,6 +65,8 @@ class PoolingShardConnection extends Connection /** * {@inheritDoc} * + * @internal The connection can be only instantiated by the driver manager. + * * @throws InvalidArgumentException */ public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null) From f5714c57449744b6c248986d1196eff303ffb1bd Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 2 Jul 2020 18:48:53 -0700 Subject: [PATCH 2/2] Mark LastInsertId internal --- UPGRADE.md | 2 ++ lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index df5f752f7c4..41c0bd1b026 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -25,6 +25,8 @@ The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been 2. Wrapper connection objects can be only created by the driver manager. 3. The driver and wrapper connection objects can be only created by the corresponding connection objects. +Additionally, the `SQLSrv\LastInsertId` class has been marked internal. + ## The `PingableConnection` interface is deprecated The wrapper connection will automatically handle the lost connection if the driver supports reporting it. diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php b/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php index 94c19f6effc..9406c425a1f 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php @@ -4,6 +4,8 @@ /** * Last Id Data Container. + * + * @internal */ class LastInsertId {