Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79602 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68964 invoked from network); 12 Dec 2014 16:13:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Dec 2014 16:13:35 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:39849] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B6/11-62606-D241B845 for ; Fri, 12 Dec 2014 11:13:34 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 70F4CB000A4; Fri, 12 Dec 2014 11:13:31 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id qREbXDOAFM7n; Fri, 12 Dec 2014 11:13:31 -0500 (EST) Received: from oa-res-26-240.wireless.abdn.ac.uk (oa-res-26-240.wireless.abdn.ac.uk [137.50.26.240]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 7FA39B000A7; Fri, 12 Dec 2014 11:13:29 -0500 (EST) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: <20141212154233.145FA261D8D@dd15934.kasserver.com> Date: Fri, 12 Dec 2014 16:13:27 +0000 Cc: jwatzman@fb.com, internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: References: <20141212154233.145FA261D8D@dd15934.kasserver.com> To: Thomas Bley X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [RFC] Nullsafe calls From: ajf@ajf.me (Andrea Faulds) Hi Thomas, > On 12 Dec 2014, at 15:42, Thomas Bley wrote: >=20 > 1) I think it would be better to have ObjectSafe Calls, e.g. >=20 > class User { > ... > public function delete() { > // delete ... > } > } > class Users { > public function find($id) { > if ($this->db->query(...)) return new User($id); > return 'not found'; > } > } >=20 > $users =3D new Users(); > $result =3D $users->find(42)?->delete(); // $result =3D 'not found'; >=20 > That way we can use scalars as return for further processing. >=20 > Definition: > Calling $obj?->foo(..) behaves identically to $obj->foo(..) if $obj is = an object. If $obj is not an $object, then it returns $obj. This would prevent adding methods for scalars or arrays in future, so I = don=92t like it. Thanks. -- Andrea Faulds http://ajf.me/