[PHP-BUG] Bug #78407 [NEW]: Contravariant Parameters bug
[email protected] ("damian dot jozwiak dot lodz at gmail dot com") Mon, 12 Aug 2019 18:55:46 +0000
| Newsgroups | php.standards |
|---|---|
| Message-ID | <[email protected]> |
From: damian dot jozwiak dot lodz at gmail dot com
Operating system: Ubuntu 18.04
PHP version: 7.4.0beta2
Package: PHP Language Specification
Bug Type: Bug
Bug description:Contravariant Parameters bug
Description:
------------
When class implement an interface it is not possible to override
function parameter.
The code works fine if base function is in class
Test script:
---------------
interface Test{
public function f1($param);
}
class inherited implements Test {
public function f1(string $param):\DOMElement{
return new \DOMElement($param);
}
}
$data = new inherited();
$node = $data->f1("node");
var_dump($node->nodeName);
Expected result:
----------------
string(4) "node"
Actual result:
--------------
Fatal error: Declaration of inherited::f1(string $param): DOMElement
must be compatible with Test::f1($param)
--
Edit bug report at https://bugs.php.net/bug.php?id=78407&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78407&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78407&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78407&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78407&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78407&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78407&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78407&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78407&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78407&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78407&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78407&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78407&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78407&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78407&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78407&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78407&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78407&r=mysqlcfg