Bug #70552 [NEW]: Declaration of Statement should be compatible with existing method
| From: | deathruler at gmail dot com | Date: | Tue, 22 Sep 2015 15:42:23 +0000 |
| Subject: | Bug #70552 [NEW]: Declaration of Statement should be compatible with existing method | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-196163@lists.php.net to get a copy of this message | ||
From: deathruler at gmail dot com
Operating system: linux
PHP version: 7.0Git-2015-09-22 (Git)
Package: Class/Object related
Bug Type: Bug
Bug description:Declaration of Statement should be compatible with existing method
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 bug report at https://bugs.php.net/bug.php?id=70552&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70552&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70552&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70552&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70552&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70552&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70552&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70552&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70552&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70552&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70552&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70552&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70552&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70552&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70552&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70552&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70552&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70552&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70552&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70552&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70552&r=mysqlcfg