Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81398 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 66505 invoked from network); 30 Jan 2015 04:03:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Jan 2015 04:03:31 -0000 Authentication-Results: pb1.pair.com header.from=ua.san.alex@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ua.san.alex@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.182 as permitted sender) X-PHP-List-Original-Sender: ua.san.alex@gmail.com X-Host-Fingerprint: 209.85.223.182 mail-ie0-f182.google.com Received: from [209.85.223.182] ([209.85.223.182:59611] helo=mail-ie0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/43-47940-2920BC45 for ; Thu, 29 Jan 2015 23:03:31 -0500 Received: by mail-ie0-f182.google.com with SMTP id ar1so921185iec.13 for ; Thu, 29 Jan 2015 20:03:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=WwgGU8LL7JPtaX9vQhpGb7pV11XK0XdoW2Pryq8/VWw=; b=Ijpj11IM/QEBvrybKNd6aDJVt/TqxOuZdon7RdXIM9hwOavhlJB9sPIZL9DFYMkjff D6bRZm1urbc1WaNs/hEqEPUlII/DnkZlrRyHNa5e2IKSbuPZQ0rS0aHQNr8gsRT8ICwX ZCssFN48gnapPqBUgEdue3RzHmqR18cvGJIuYg0CUZygekSFKjDX8NhqMR650RzBTiQn ddvG0PDD9qPhx8rAljBIwSrqKpYja7v2FWsMcIlZDzI7f2iOH7pMBeWSpGiZXzN3xYgs 5hzVJErBJOij5C0u6DXnNIzBIoWgE5CylWY3oXxOno5al7CsQ6oOZ0ei5iGpKG/Wbu7i rhKw== MIME-Version: 1.0 X-Received: by 10.42.20.194 with SMTP id h2mr4247170icb.24.1422590606281; Thu, 29 Jan 2015 20:03:26 -0800 (PST) Received: by 10.50.93.3 with HTTP; Thu, 29 Jan 2015 20:03:26 -0800 (PST) In-Reply-To: References: Date: Fri, 30 Jan 2015 06:03:26 +0200 Message-ID: To: Juan Basso Cc: internals Content-Type: multipart/alternative; boundary=20cf302925e0bf8f8c050dd6afcb Subject: Re: [PHP-DEV] Use "caller" keyword, to access object caller. From: ua.san.alex@gmail.com ("S.A.N") --20cf302925e0bf8f8c050dd6afcb Content-Type: text/plain; charset=UTF-8 Yes. But this creates a static link that will not be constantly changing context to the calls, the keyword will give a dynamic abstract communication. 2015-01-30 5:50 GMT+02:00 Juan Basso : > Usually it is solved sending the $this instance to class C constructor and > C object storing it in some attribute, solving the problem. I don't think a > new keyword would help. > > Juan Basso > > On Thu, Jan 29, 2015 at 9:53 PM, S.A.N wrote: > >> 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. >> >> > >> 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. >> > > --20cf302925e0bf8f8c050dd6afcb--