Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67254 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48253 invoked from network); 1 May 2013 18:12:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 May 2013 18:12:28 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 209.85.212.46 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.212.46 mail-vb0-f46.google.com Received: from [209.85.212.46] ([209.85.212.46:42654] helo=mail-vb0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4B/22-28617-B0B51815 for ; Wed, 01 May 2013 14:12:28 -0400 Received: by mail-vb0-f46.google.com with SMTP id 10so1402176vbe.5 for ; Wed, 01 May 2013 11:12:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to:cc :content-type:x-gm-message-state; bh=twPPd/jP1cSRwGcHZFnVX1J27oTPWBGRKgMrVpbK+Sc=; b=VUGCK9mugXAkaXJRu7EblHNu0sb2iWnr8oYlNECHMHvTaVWRT4EcPCILaK0VOKdnMq h/PD7KRV7pEatDtY6ba/+BDo/Q0HP/PoSQAitQeFnBg3+d2BsTMnOacAzxA/UU4Ik4C/ 9ITajclNU5CRA6mtKvIp9SidSx2oD6fDp+b0duQktb8Zbb+iE8YrLbRhIjhZ18UihZD3 o95K4GiyhimXwL8AEC/UzREF3JtUsDIjNC98nrSkRWW2OIi+lpbHxXkX4dbyzqw4piqL EWADUJv+2oJHlJX609gwZ8FniqCmYBuEohu9YjDFkrgkVqFPWP4yMpT607G1DuAyBZ6l 0kWg== MIME-Version: 1.0 X-Received: by 10.52.237.137 with SMTP id vc9mr971591vdc.102.1367431945360; Wed, 01 May 2013 11:12:25 -0700 (PDT) Received: by 10.58.28.134 with HTTP; Wed, 1 May 2013 11:12:25 -0700 (PDT) Date: Wed, 1 May 2013 14:12:25 -0400 Message-ID: To: M.Ford@leedsmet.ac.uk Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=089e011767515babc304dbac0fe1 X-Gm-Message-State: ALoCoQndN+vC1JhMb7+nfFRFVxQutNB7ZB7iQtqX/5LzHJwCiA3WVWqK1TrbuM0eJO6v+qRCONpf Subject: RE: [PHP-DEV] property de-referencing From: rasmus@mindplay.dk (Rasmus Schultz) --089e011767515babc304dbac0fe1 Content-Type: text/plain; charset=ISO-8859-1 Hi Mike, Missed your e-mail because it went to the list only. What you're demonstrating here is functionally equivalent to the simple example I provided. (The example was intended to show how this feature works, not necessarily how you would use it in practice.) The key difference, is that a native reference carries no contextual information with it - a form-helper for instance can't determine which object the referenced property belongs to, the name of the property, or even the fact that the variable is referencing an object-property in the first place. You also can't use the & operator to create a reference to a virtual (__get/__set) property, because you would be creating a reference to the value that is returned by the __get() method, rather than to a (virtual) property of an object. That's why form-helpers currently store references to objects, and reference properties using strings - rather than using native variable-references as in your example. --- From: "Ford, Mike" To: PHP internals Cc: Date: Wed, 1 May 2013 13:20:32 +0000 Subject: RE: [PHP-DEV] property de-referencing I know I'm still somewhat of a beginner with OOP, and not at all into large-scale OOP frameworks (yet!), but I'm really struggling to understand why the existing & reference operator doesn't suffice for what you are after? If you could explain in words of as few syllables as possible what you would want to add to: class User { public $name; } $user = new User; $user->name = 'Rasmus'; $nameprop = &$user->name; var_dump($nameprop); // => 'Rasmus' $nameprop = 'Bob'; var_dump($nameprop); // => 'Bob' I would be immensely grateful, as I might then stand a chance of deciding whether I'm with you or agin you...! Cheers! Mike --089e011767515babc304dbac0fe1--