|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-07-12 14:19 UTC] carusogabriel@php.net
[2020-07-12 14:36 UTC] nikic@php.net
-Status: Open
+Status: Not a bug
[2020-07-12 14:36 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 13 00:00:02 2025 UTC |
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