Bug #72628 [Opn->Csd]: PDO constructer return null when arguments are unexpected types
| From: | nikic@php.net | Date: | Wed, 20 Jul 2016 10:12:26 +0000 |
| Subject: | Bug #72628 [Opn->Csd]: PDO constructer return null when arguments are unexpected types | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-202438@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72628&edit=1
ID: 72628
Updated by: nikic@php.net
Reported by: kazu9su at gmail dot com
Summary: PDO constructer return null when arguments are
unexpected types
-Status: Open
+Status: Closed
Type: Bug
Package: PDO related
PHP Version: 5.6.23
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
This has been fixed in PHP 7.0 as part of https://wiki.php.net/rfc/internal_constructor_behaviour.
Previous Comments:
------------------------------------------------------------------------
[2016-07-20 08:33:31] kazu9su at gmail dot com
Description:
------------
PDO contructer return null and output warning() when given unexpected type arguments.
I think it is better that throw PDO exception with relevant message or update PHPDoc to indicate
this specification.
How about that?
Test script:
---------------
<?php
try {
$pdo = new PDO('pgsql:host=db;dbname=hoge', 'postgres', [], []);
var_dump(is_null($pdo));
} catch(PDOException $e) {
var_dump($e->getMessage());
}
Expected result:
----------------
string(64) "PDO::__construct() expects parameter 3 to be string, array given"
Actual result:
--------------
Warning: PDO::__construct() expects parameter 3 to be string, array given in
/Users/kazushige.tominaga/test-prestissimo/hoge.php on line 2
bool(true)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72628&edit=1