ID: 46157 Updated by: [EMAIL PROTECTED] Reported By: ob dot php at daevel dot fr -Status: Open +Status: Assigned Bug Type: PDO related Operating System: Linux PHP Version: 5.2.6 -Assigned To: +Assigned To: felipe
Previous Comments: ------------------------------------------------------------------------ [2008-09-23 10:15:12] ob dot php at daevel dot fr Description: ------------ Hello, the prototype of PDOStatement::fetchObject() say that the first parameter ($class_name) is required. But you can call it without specifying this parameter, and without any error. So, witch is wrong ? Reproduce code: --------------- <?php // With E_STRICT this produce an error because $class_name is set as optional here. class myPDOStatement extends PDOStatement { protected function __construct() { } public function fetchObject( $class_name = NULL, $ctor_args = NULL ) { return parent::fetchObject(); } } echo PHP_EOL; // To verify the current prototype : Reflection::export(new ReflectionMethod('PDOStatement', 'fetchObject')); $db = new PDO('sqlite::memory:'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->exec("create table test ( id integer not null )"); $db->exec("insert into test values ( 5 )"); // But as you can see, $class_name is not required if( $res = $db->query( "select id from test" ) ){ while( $row = $res->fetchObject() ){ var_dump( $row ); } } Expected result: ---------------- Method [ <internal:PDO> public method fetchObject ] { - Parameters [2] { Parameter #0 [ <optional> $class_name ] Parameter #1 [ <optional> $ctor_args ] } } object(stdClass)#3 (1) { ["id"]=> string(1) "5" } Actual result: -------------- Strict Standards: Declaration of secondPDOStatement::fetchObject() should be compatible with that of PDOStatement::fetchObject() in /home/dev-olivier/pdoTest.php on line 13 Method [ <internal:PDO> public method fetchObject ] { - Parameters [2] { Parameter #0 [ <required> $class_name ] Parameter #1 [ <optional> $ctor_args ] } } object(stdClass)#3 (1) { ["id"]=> string(1) "5" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46157&edit=1