php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70552 Declaration of Statement should be compatible with existing method
Submitted: 2015-09-22 15:42 UTC Modified: 2015-12-11 18:10 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: deathruler at gmail dot com Assigned:
Status: Duplicate Package: Class/Object related
PHP Version: 7.0Git-2015-09-22 (Git) OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
13 + 10 = ?
Subscribe to this entry?

 
 [2015-09-22 15:42 UTC] 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 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-24 15:47 UTC] 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-12-11 18:10 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2015-12-11 18:10 UTC] nikic@php.net
Duplicate of https://bugs.php.net/bug.php?id=70839.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 04:01:30 2024 UTC