From aec9b177f9aacee762620fd5ecbe7c0a11761f7a Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Tue, 7 Feb 2023 10:39:52 -0300 Subject: [PATCH] Fix type assumptions about `Connection::lastInsertId()` --- src/Connection.php | 2 -- src/Driver/Connection.php | 8 +++----- src/Driver/IBMDB2/Connection.php | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Connection.php b/src/Connection.php index 2549f04132f..1e39b6d214e 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -878,8 +878,6 @@ public function getTransactionNestingLevel(): int * * If the underlying driver does not support identity columns, an exception is thrown. * - * @return int|string The last insert ID, as an integer or a numeric string. - * * @throws Exception */ public function lastInsertId(): int|string diff --git a/src/Driver/Connection.php b/src/Driver/Connection.php index f5229a2d298..eaafb01ead7 100644 --- a/src/Driver/Connection.php +++ b/src/Driver/Connection.php @@ -46,7 +46,7 @@ public function exec(string $sql): int|string; /** * Returns the ID of the last inserted row. * - * This method returns an integer or a numeric string representing the value of the auto-increment column + * This method returns an integer or a string representing the value of the auto-increment column * from the last row inserted into the database, if any, or throws an exception if a value cannot be returned, * in particular when: * @@ -54,10 +54,8 @@ public function exec(string $sql): int|string; * - the last statement dit not return an identity (caution: see note below). * * Note: if the last statement was not an INSERT to an autoincrement column, this method MAY return an ID from a - * previous statement. DO NOT RELY ON THIS BEHAVIOR which is driver-dependent: always use getLastInsertId() right - * after executing an INSERT statement. - * - * @return int|string The last insert ID, as an integer or a numeric string. + * previous statement. DO NOT RELY ON THIS BEHAVIOR which is driver-dependent: always call this method right after + * executing an INSERT statement. * * @throws Exception */ diff --git a/src/Driver/IBMDB2/Connection.php b/src/Driver/IBMDB2/Connection.php index ae437ce3de9..26b288473d4 100644 --- a/src/Driver/IBMDB2/Connection.php +++ b/src/Driver/IBMDB2/Connection.php @@ -77,7 +77,7 @@ public function exec(string $sql): int|string return db2_num_rows($stmt); } - public function lastInsertId(): int|string + public function lastInsertId(): string { $lastInsertId = db2_last_insert_id($this->connection);