Req #79824 [Opn]: Use late binding scope instead of scope in stack trace
| From: | si dot schubert at live dot de | Date: | Sun, 19 Jul 2020 12:03:27 +0000 |
| Subject: | Req #79824 [Opn]: Use late binding scope instead of scope in stack trace | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-228117@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79824&edit=1
ID: 79824
User updated by: si dot schubert at live dot de
Reported by: si dot schubert at live dot de
Summary: Use late binding scope instead of scope in stack
trace
Status: Open
Type: Feature/Change Request
Package: *General Issues
Operating System: Debian GNU/Linux 10 (buster)
PHP Version: 8.0.0alpha2
Block user comment: N
Private report: N
New Comment:
thanks for checking. If it is not a bug, feel free to close it. From a userland perspective it felt
weird to get A::new() when actually calling B::new(). But this is maybe also caused by the fact,
that I do not fully understand how objects are built in PHP. Is there an instance A(i) when creating
B(i)? I always assumed, that there is just B(i) build from B (plus A where needed).
Previous Comments:
------------------------------------------------------------------------
[2020-07-10 12:11:35] nikic@php.net
This has no relation to the static return type. I'm also not convinced showing the LSB scope
instead of the scope makes sense.
------------------------------------------------------------------------
[2020-07-09 19:15:06] si dot schubert at live dot de
Description:
------------
the message and stack trace references the wrong class
Test script:
---------------
class A
{
public static function new(): static
{
return new self();
}
}
class B extends A
{
}
B::new();
Expected result:
----------------
Fatal error: Uncaught TypeError: B::new(): Return value must be of type B, A returned in
/app/bin/runner:8
Stack trace:
#0 /app/bin/runner(16): B::new()
#1 {main}
thrown in /app/bin/runner on line 8
Actual result:
--------------
Fatal error: Uncaught TypeError: A::new(): Return value must be of type B, A returned in
/app/bin/runner:8
Stack trace:
#0 /app/bin/runner(16): A::new()
#1 {main}
thrown in /app/bin/runner on line 8
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79824&edit=1