Bug #79754 [NEW]: Covariance fails with mixed type

From: Date: Sun, 28 Jun 2020 13:06:19 +0000
Subject: Bug #79754 [NEW]: Covariance fails with mixed type
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227708@lists.php.net to get a copy of this message
From: raincomplain at outlook dot com Operating system: PHP version: 8.0.0alpha1 Package: Class/Object related Bug Type: Bug Bug description:Covariance fails with mixed type Description: ------------ Since mixed type indicates the absence of a type then one would assume that omitting a return type in a child class's method that returns mixed type in a parent class is fine! but PHP refuses to compile Test script: --------------- class Foo { function fun(): mixed { return 33; } } class Bar extends Foo { function fun() { return 33; } } Expected result: ---------------- The expected is to compile with no error Actual result: -------------- Fatal error: Declaration of Bar::fun() must be compatible with Foo::fun(): mixed -- Edit bug report at https://bugs.php.net/bug.php?id=79754&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79754&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79754&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79754&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79754&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79754&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79754&r=support Expected behavior: https://bugs.php.net/fix.php?id=79754&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79754&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79754&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79754&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79754&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79754&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79754&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79754&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79754&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79754&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79754&r=mysqlcfg

« previous php.bugs (#227708) next »