php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52003 Incorrect PDOStatement::execute() signature
Submitted: 2010-06-05 22:53 UTC Modified: 2015-08-31 22:28 UTC
Votes:5
Avg. Score:4.4 ± 0.8
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:4 (100.0%)
From: me at paulofreitas dot me Assigned: iliaa
Status: Assigned Package: PDO Core
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID:
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: me at paulofreitas dot me
New email:
PHP Version: OS:

 

 [2010-06-05 22:53 UTC] me at paulofreitas dot me
Description:
------------
Manual says PDOStatement::execute() signature is:

bool PDOStatement::execute  ([  array $input_parameters = array()  ] )

But in fact it is:

bool PDOStatement::execute  ([  $input_parameters = null  ] )

Test script:
---------------
<?php

class DBStatement extends PDOStatement
{
    public function execute(array $input_parameters = array())
    {
        return parent::execute($input_parameters);
    }
}

$PDO = new PDO('mysql:host=127.0.0.1', 'root', '');
$PDO->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement'));

Expected result:
----------------
No errors

Actual result:
--------------
Strict Standards: Declaration of DBStatement::execute() should be compatible with that of PDOStatement::execute() in /media/ext/Web/htdocs/test/bug.php on line 9

Patches

ZEND_ARG_ARRAY_INFO (last revision 2010-06-06 04:13 UTC) by pierrick@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-06 06:13 UTC] pierrick@php.net
The following patch has been added/updated:

Patch Name: ZEND_ARG_ARRAY_INFO
Revision:   1275797622
URL:        http://bugs.php.net/patch-display.php?bug=52003&patch=ZEND_ARG_ARRAY_INFO&revision=1275797622
 [2010-10-19 07:07 UTC] kalle@php.net
-Type: Documentation Problem +Type: Bug -Package: Documentation problem +Package: PDO related -Assigned To: +Assigned To: pierrick
 [2010-10-19 07:07 UTC] kalle@php.net
Pierrick, why don't you commit that patch the src? And add a changelog entry if reasonable for PDOStatement::execute() :)
 [2012-01-30 05:52 UTC] larry at ldrutledge dot com
The situation appears to be unchanged in 5.3.9. The manual still shows a type hint of array but a method in an extended class still triggers a warning unless the type hint is omitted.
 [2012-09-09 14:37 UTC] reeze dot xia at gmail dot com
This seems been forgotten by pierrick.
 [2012-09-10 02:32 UTC] laruence@php.net
maybe change to doc problem, there maybe already some user defined their extended 
class with the *wrong* signature.
 [2012-11-17 00:58 UTC] pierrick@php.net
I never committed this patch because it was breaking some php code by adding 
strict errors. We should (as said in the previous comment) update the 
documentation.

I'm assigning this to you Ilia since you're the PDO primary maintainer. Do you 
also think it's best to just update the documentation ? Thanks for your feedback
 [2012-11-17 00:58 UTC] pierrick@php.net
-Assigned To: pierrick +Assigned To: iliaa
 [2012-11-17 01:00 UTC] iliaa@php.net
I think the patch make sense, we should update the docs to reflect the patch.
 [2012-11-17 06:08 UTC] pierrick@php.net
Ok then I'll commit it on 5.3 and > or on 5.5 and > ?
 [2013-02-06 22:44 UTC] rick at wrep dot nl
This is still not fixed in the documentation, it would be great if the 
documentation could be updated to reflect the real situation!
 [2013-02-13 23:42 UTC] me at paulofreitas dot me
-: v1d4l0k4 at gmail dot com +: me at paulofreitas dot me
 [2013-02-13 23:42 UTC] me at paulofreitas dot me
Using PHP 5.4.6 I noticed that the Strict Standards error message was improved, now it includes the expected signature, which actually helps more than before:

Strict Standards: Declaration of DBStatement::execute() should be compatible with PDOStatement::execute($bound_input_params = NULL) in Unknown on line 0

If it won't get patched, please, don't forget to update the docs! (if php-doc was already mirrored on GitHub I'd have done it myself – hint)
 [2014-01-01 12:49 UTC] felipe@php.net
-Package: PDO related +Package: PDO Core
 [2015-08-31 22:28 UTC] cmb@php.net
IMO, this is not a documentation problem, but rather an
implementation bug. While the ARG_INFO is untyped[1], the
respective ZPP expects a nullable array[2]. Actually, this
inconsistency should be fixed, instead of weakening the docs.

[1] <https://github.com/php/php-src/blob/php-7.0.0RC1/ext/pdo/pdo_stmt.c#L44-L46>
[2] <https://github.com/php/php-src/blob/php-7.0.0RC1/ext/pdo/pdo_stmt.c#L441>
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Fri Feb 24 19:01:40 2017 UTC