Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67236 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74943 invoked from network); 30 Apr 2013 23:55:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2013 23:55:58 -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.220.169 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 209.85.220.169 mail-vc0-f169.google.com Received: from [209.85.220.169] ([209.85.220.169:38765] helo=mail-vc0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/5E-18873-E0A50815 for ; Tue, 30 Apr 2013 19:55:58 -0400 Received: by mail-vc0-f169.google.com with SMTP id gd11so934518vcb.14 for ; Tue, 30 Apr 2013 16:55:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:x-gm-message-state; bh=4E3FDjxufB9qNroVXJpbstx2JSi+nCfQft/dO3tN3z4=; b=Ih/cDzb1o/1CH8Mba/ty0BgE3luTbwurEIekTYr3WAkdJdzyFd6pyWOnB/Yk0KSFLp ex6Slyuur+/i78p+qUzDt8MgqepzQFASAM2GVEDVD+bM9vRPSUaerrKDuNTCqgO+okq9 JXi4t6DQgi2n2wG4WzdA6Yt8VZ+5q9/iObGHvrmgDmRR6i2dDIbTQbThvZ/I2tUYDQQv HOxheiMntAItkHeamXoJUYYK+2qdze2LqTPwcND3XCv6uFpLsj+DHZfQHTopgPbFCfdh Q7No5ZZ1lM9E7B6nasHMPqJrIi5NSAYrYcJ0KP+IP9IYWcttRB7mk3tk6/Oewxbr43+I To6A== MIME-Version: 1.0 X-Received: by 10.52.70.108 with SMTP id l12mr170686vdu.40.1367366155210; Tue, 30 Apr 2013 16:55:55 -0700 (PDT) Received: by 10.58.28.134 with HTTP; Tue, 30 Apr 2013 16:55:55 -0700 (PDT) In-Reply-To: References: <6245ED6B-2BF7-47B7-80C0-D3B3D8E0B312@strojny.net> <51803086.6020002@sugarcrm.com> <518030FD.5030504@lerdorf.com> Date: Tue, 30 Apr 2013 19:55:55 -0400 Message-ID: To: Adam Harvey Cc: PHP internals Content-Type: multipart/alternative; boundary=20cf307c9b6af5dc7d04db9cbd93 X-Gm-Message-State: ALoCoQnqwjMrT0DeohDmKbKMuAPzjQHnRWCpyHvmJBnY9EGrjTTfurz+GZUrpKRPAEJaCf1B5LT0 Subject: Re: [PHP-DEV] property de-referencing From: rasmus@mindplay.dk (Rasmus Schultz) --20cf307c9b6af5dc7d04db9cbd93 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Apr 30, 2013 at 7:34 PM, Adam Harvey wrote: > I would caution against generalising use cases. Personally, ::class is > something I can use multiple times a day. This I'm not so sure about. > > Your use case is not my use case, and vice versa. :) > What is your use-case then? DI perhaps? > Why does this have to be a language feature? > I already covered that. > It obviously already works in userland, as your own Symfony 2 examples > show. > As explained, this is not intended to solve a problem that can't currently by solved by other means, but to strengthen the static aspects of the language. > One could > write a PropertyReference class right now with literally the only > difference being the lack of a builtin operator (ie new > PropertyReference($obj, 'prop') versus ^$obj->prop): the fact that > nobody seems to have done this in a major framework I know of suggests > that there isn't a strong need for encapsulating the indirection > beyond the $obj->$prop syntax that's worked forever. > Look at the Symfony form-builder example - encapsulating the indirection is *precisely* what they're doing: the object reference is stored in the form-builder, and property-names are added subsequently. Yes, you can already create property-references at run-time - for that matter, you could already use new ReflectionProperty($obj, 'prop') to do what you demonstrated above. But the property-name, in the source-code, is a string - it has no literal relationship to YourClass::$prop where as ^$obj->prop does. No mainstream framework provides a PropertyReference class, because it wouldn't accomplish anything - the property-name is still a string, it's still unchecked, and still can't (reliably) be used in static analysis. --20cf307c9b6af5dc7d04db9cbd93--