Bug #79840 [NEW]: Union Type in argument reports types swapped in error message
| From: | carusogabriel@php.net | Date: | Sun, 12 Jul 2020 14:17:52 +0000 |
| Subject: | Bug #79840 [NEW]: Union Type in argument reports types swapped in error message | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-227977@lists.php.net to get a copy of this message | ||
From: carusogabriel
Operating system: Any
PHP version: master-Git-2020-07-12 (Git)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Union Type in argument reports types swapped in error message
Description:
------------
Playing around with PHP 8, I found something in Union Type's error
messages, specific in typed arguments: the types are report in a
different position from where they were declared.
Test script:
---------------
<?php
class ValidMagicMethods {
public function myMethod(string $name, array $arguments): mixed {}
}
final class NarrowedReturnType extends ValidMagicMethods {
public function myMethod(string|array $name, bool $arguments):
string|float|null {}
}
Expected result:
----------------
Fatal error: Declaration of NarrowedReturnType::myMethod(array|string
$name, bool $arguments): string|float|null must be compatible with
ValidMagicMethods::myMethod(string $name, array $arguments): mixed in
/in/WE96o on line 8
Actual result:
--------------
Fatal error: Declaration of NarrowedReturnType::myMethod(string|array
$name, bool $arguments): string|float|null must be compatible with
ValidMagicMethods::myMethod(string $name, array $arguments): mixed in
/in/WE96o on line 8
--
Edit bug report at https://bugs.php.net/bug.php?id=79840&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79840&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79840&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79840&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79840&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79840&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79840&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79840&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79840&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79840&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79840&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79840&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79840&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79840&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79840&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79840&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79840&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79840&r=mysqlcfg