[php-src] Issue #9529: PDOException::getCode() return value type is string

From: Date: Tue, 13 Sep 2022 06:58:06 +0000
Subject: [php-src] Issue #9529: PDOException::getCode() return value type is string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242407@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9529
Author: Yurunsoft

### Description

The following code:

```php
<?php

declare(strict_types=1);

try
{
    $pdo = new PDO('mysql:host=127.0.0.1', 'root', 'root');
    $pdo->query('select x');
}
catch (\Throwable $e)
{
    var_dump($e->getCode());
}
```

Resulted in this output:
```
string(5) "42S22"
```

But I expected this output instead:

-

---

Is it possible to change the return value of Throwable::getCode() to
int|string?

https://github.com/php/php-src/blob/eb22f1a31ad02699c718fe15ce648acd401900e4/Zend/zend_exceptions.stub.php#L12

### PHP Version

8.0.21

### Operating System

Ubuntu 20.04


Thread (1 message)

  • Yurunsoft
« previous php.bugs (#242407) next »