|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesfix-anonymous-class-union-typehints (last revision 2021-01-13 09:46 UTC by daniil at daniil dot it)Pull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2021-01-06 12:20 UTC] cmb@php.net
-Status: Open
+Status: Verified
[2021-01-06 12:20 UTC] cmb@php.net
[2021-01-13 09:46 UTC] daniil at daniil dot it
[2021-01-13 14:13 UTC] cmb@php.net
[2021-01-14 09:04 UTC] nikic@php.net
[2021-01-14 09:04 UTC] nikic@php.net
-Status: Verified
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 01:00:01 2025 UTC |
Description: ------------ Type errors thrown for union typehints containing self in an anonymous class contain only class@anonymous in the error message, without the full typehint. Test script: --------------- class a { public function test(): self|string { return new \stdClass; } }; $b = new class { public function test(): self|string { return new \stdClass; } }; try { (new a)->test(); } catch (\Throwable $e) { echo $e->getMessage().PHP_EOL; } try { $b->test(); } catch (\Throwable $e) { echo $e->getMessage().PHP_EOL; } Expected result: ---------------- a::test(): Return value must be of type a|string, stdClass returned class@anonymous::test(): Return value must be of type class@anonymous|string, stdClass returned Actual result: -------------- a::test(): Return value must be of type a|string, stdClass returned class@anonymous::test(): Return value must be of type class@anonymous, stdClass returned