[php-src] Issue #12294: PDOException::getCode() returns string instead of int
| From: | 8ctopus | Date: | Mon, 25 Sep 2023 10:04:28 +0000 |
| Subject: | [php-src] Issue #12294: PDOException::getCode() returns string instead of int | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-245429@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/12294
Author: 8ctopus
### Description
The following code:
```php
<?php
declare(strict_types=1);
use PDO;
use PDOException;
try {
$database = new PDO('sqlite::memory:', null, null, null);
$query = $database->prepare('SELECT * FROM test2');
$query->execute();
} catch (PDOException $exception) {
$code = $exception->getCode();
echo gettype($code);
}
```
Resulted in this output:
```
string
```
But I expected this output instead:
```
int
```
https://www.php.net/manual/en/class.pdoexception
```
final public Exception::getCode(): int
```
### PHP Version
php 8.2.10
### Operating System
alpine 3.18.3