The reason for creating circular references, usually due to the need to
bind objects.

But this relationship can often be obtained from the context of the call.

It will be very convenient to have a keyword that will return reference to
an object, which caused this object.

Sorry for my English, I'm not a native speaker.
A simple example below shows the behavior that we need.

<?php

class A
{
    public function __construct() {
        $this->object = new C;
    }
}

class B
{
    public function __construct() {
        $this->object = new C;
    }
}

class C
{
    public function getCaller() {
        return caller::class;
    }
}

$a = new A;
$b = new B;
$c = new C;

$a->object->getCaller(); // return A
$b->object->getCaller(); // return B

$c->getCaller(); // Fatal Error - undefined caller context

?>

Create a new keyword can cause problems with backward compatibility...
Perhaps you can solve a problem to using an existing keyword?

Thank you for any feedback.

Reply via email to