Bug #70552 [Opn->Dup]: Declaration of Statement should be compatible with existing method
| From: | nikic@php.net | Date: | Fri, 11 Dec 2015 18:10:20 +0000 |
| Subject: | Bug #70552 [Opn->Dup]: Declaration of Statement should be compatible with existing method | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-197806@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70552&edit=1
ID: 70552
Updated by: nikic@php.net
Reported by: deathruler at gmail dot com
Summary: Declaration of Statement should be compatible with
existing method
-Status: Open
+Status: Duplicate
Type: Bug
Package: Class/Object related
Operating System: linux
PHP Version: 7.0Git-2015-09-22 (Git)
Block user comment: N
Private report: N
New Comment:
Duplicate of https://bugs.php.net/bug.php?id=70839.
Previous Comments:
------------------------------------------------------------------------
[2015-09-24 15:47:33] alec at alec dot pl
This comes probably from https://wiki.php.net/rfc/reclassify_e_strict
or is related, but personally I also do not like the change in this particular case.
------------------------------------------------------------------------
[2015-09-22 15:42:20] deathruler at gmail dot com
Description:
------------
I've created a class that extends PDO and a class that extends PDOStatement.
When upgrading to PHP 7.0 RC2, it gave me a strict warning on a code that gave no issues before.
What is particular is that the result error says that on line 90 is where the error occurred, but
that's wrong as it contains the ending bracket of the Statement class and thus is incorrect
hoping that this error is also unexpected behavior.
Cause all I wanted to do is to let the PDO "execute" method do more then default.
Just because the method shares the same name, doesn't mean it must share the same arguments (at
least in my opinion).
Test script:
---------------
<?php
class Statement extends PDOStatement{
public function execute(...$args){ #because this arg list is different from pdo arg list it gives
a strict error.
# do stuff
parent::execute();
}
public function __construct($handle){}
}
class Database extends PDO{
function __construct(){
parent::__construct($dsn, $username, $password, [parent::ATTR_STATEMENT_CLASS =>
['Statement', [$this]]]);
}
}
?>
Expected result:
----------------
I expect to see no strict errors ;)
Actual result:
--------------
Warning: Declaration of Statement::execute(...$args) should be compatible with
PDOStatement::execute($bound_input_params = NULL) in /path/to/statement.php on line 90
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70552&edit=1