|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74488 Just flat wrong: "Warning: Declaration of * should be compatible with"
Submitted: 2017-04-22 11:52 UTC Modified: 2017-04-22 12:35 UTC
From: appacc2040 at gmail dot com Assigned:
Status: Not a bug Package: Compile Warning
PHP Version: 7.1.4 OS:
Private report: No CVE-ID: None
 [2017-04-22 11:52 UTC] appacc2040 at gmail dot com
"Warning: Declaration of * should be compatible with"

In the real world abstracted features work this way all the time.  This warning is an arbitrary and artificial idea that has no basis in the real world.

PHP Warning:  Declaration of combinationLock::unlock($combination) should be compatible with abstractLock::unlock() in test.php on line 23

PHP Warning:  Declaration of paddleLock::unlock($key) should be compatible with abstractLock::unlock() in test.php on line 32

Test script:
class abstractLock
    private $locked = true;
    public function unlock()
    public function lockStatus()
        if($this->locked) return "Locked\n";
        else return "Unlocked\n";

class combinationLock extends abstractLock
    private $combination = '32-10-21'; // combination
    public function unlock($combination)        // unlock WITH combination
        if($this->combination == $combination) parent::unlock();

class paddleLock extends abstractLock
    private $key = '100,70,80,30,50,90,60,40,100'; // ridge heights
    public function unlock($key)                            // unlock WITH key
        if($this->key == $key) parent::unlock();

$lock1 = new paddleLock();
echo "paddleLock is " . $lock1->lockStatus();
echo "paddleLock is " . $lock1->lockStatus();

$lock2 = new combinationLock();
echo "combinationLock is " . $lock2->lockStatus();
echo "combinationLock is " . $lock2->lockStatus();

Expected result:
No warning about things that happen all the time in the real world.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2017-04-22 11:58 UTC]
-Status: Open +Status: Not a bug
 [2017-04-22 12:15 UTC] spam2 at rhsoft dot net
No they are not because when someone wants Java then he can use Java 

And that in case of return types the warning becomes a fatal error is a typical php inconsistency like soap extension, require and call to disabled functions not throwing throwable exceptions
 [2017-04-22 12:23 UTC] spam2 at rhsoft dot net
At least give us "somekeyword_stating_dontmatter class extends parent_class"
 [2017-04-22 12:34 UTC]
-Block user comment: No +Block user comment: Yes
 [2017-04-22 12:35 UTC]
If you wish to suggest a syntax extension, please submit a proposal to the internals mailing list. There will be no need for further comments on this issue.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Sep 27 21:01:24 2023 UTC