Bug #74488 [NEW]: Just flat wrong: "Warning: Declaration of * should be compatible with"

From: Date: Sat, 22 Apr 2017 11:52:42 +0000
Subject: Bug #74488 [NEW]: Just flat wrong: "Warning: Declaration of * should be compatible with"
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208710@lists.php.net to get a copy of this message
From: appacc2040 at gmail dot com Operating system: PHP version: 7.1.4 Package: Compile Warning Bug Type: Bug Bug description:Just flat wrong: "Warning: Declaration of * should be compatible with" Description: ------------ "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: --------------- <?php class abstractLock { private $locked = true; public function unlock() { $this->locked=false; } 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(); $lock1->unlock('100,70,80,30,50,90,60,40,100'); echo "paddleLock is " . $lock1->lockStatus(); $lock2 = new combinationLock(); echo "combinationLock is " . $lock2->lockStatus(); $lock2->unlock('32-10-21'); echo "combinationLock is " . $lock2->lockStatus(); ?> Expected result: ---------------- No warning about things that happen all the time in the real world. -- Edit bug report at https://bugs.php.net/bug.php?id=74488&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74488&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74488&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74488&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74488&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74488&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74488&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74488&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74488&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74488&r=support Expected behavior: https://bugs.php.net/fix.php?id=74488&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74488&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74488&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74488&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74488&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74488&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74488&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74488&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74488&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74488&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74488&r=mysqlcfg

« previous php.bugs (#208710) next »