Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51008 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77813 invoked from network); 11 Dec 2010 18:35:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2010 18:35:05 -0000 Authentication-Results: pb1.pair.com header.from=quickshiftin@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=quickshiftin@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.45 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: quickshiftin@gmail.com X-Host-Fingerprint: 209.85.214.45 mail-bw0-f45.google.com Received: from [209.85.214.45] ([209.85.214.45:43084] helo=mail-bw0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AE/C0-02666-854C30D4 for ; Sat, 11 Dec 2010 13:35:04 -0500 Received: by bwz16 with SMTP id 16so5558930bwz.32 for ; Sat, 11 Dec 2010 10:35:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=eIxCjZKHfls/Rr4P5YSpGN67ipl3sBOPD0qhYmvDQv0=; b=pXRPaxbgFHdQXsPym++5CvjgSWXzHYPsrm1Ud0oX/WaDBNgJiA2KLcz683LOnqR21Z fl6e+JVMp8xTQko7H2ESNR+3p8frEx6Isajfk7MqsfTx/M0ICorfaAy06Zxc/OIPl4vS B8UBMV7PaLgsBAJJVam8JacCuXxJkSOPjZD/g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=VndcGag0Y6oz+60ZZ9kFWOh0f2uw+m4w/1Lo+T+TeuHKA07X25hcQbG6NTIhKIpFec AEq588ntlPM/kKFTATzVu/kmcDxtt1KlErV4NGzAeUQT3hvMCVjYoDKTLHxdK6lx56IB Kl8/DEJLhf8UvJBkmv2OrJnBbPRIaaRsveR98= MIME-Version: 1.0 Received: by 10.204.61.199 with SMTP id u7mr2066490bkh.6.1292092501047; Sat, 11 Dec 2010 10:35:01 -0800 (PST) Received: by 10.204.112.208 with HTTP; Sat, 11 Dec 2010 10:35:01 -0800 (PST) In-Reply-To: <89C52156-CF92-4DDB-8BA4-4ABF6883512C@stefan-marr.de> References: <89C52156-CF92-4DDB-8BA4-4ABF6883512C@stefan-marr.de> Date: Sat, 11 Dec 2010 11:35:01 -0700 Message-ID: To: Stefan Marr Cc: "internals@lists.php.net Development" Content-Type: multipart/alternative; boundary=001636c5a5eb8aba7c049726ba5b Subject: Re: [PHP-DEV] Traits and Properties From: quickshiftin@gmail.com (Nathan Nobbe) --001636c5a5eb8aba7c049726ba5b Content-Type: text/plain; charset=UTF-8 On Sat, Dec 11, 2010 at 9:47 AM, Stefan Marr wrote: > Hi: > > Traits do not provide any special provisioning for handling properties, > especially, there is no language solution for handling colliding property > names. > The current solution/idiom for handling state safely in a trait is to use > either abstract set/get methods or an abstract get that returns a reference > to the property in the class. > > However, at the moment it is possible to define properties in a trait: > > trait Foo { > private $a; > public $foo; > } > > For the moment, that information is completely ignored, thus: > > class Bar { > use Foo; > } > property_exists('Bar', 'a') === false > > > Well, and that is a rather inconsistent status-quo. > > I would like to have that fixed in one or another way. > > One possibility would be to forbid property definition in a trait > altogether. > That reduces a bit the possibility to have wrong expectations about > properties, however, the dynamic property creation is still possible. > > Another way would be to merge the properties in the composing class. > The question here would be how to treat visibility modifiers: how to merge > public and private, should it result in public, or private? > And, to discorage users to go this way, should there be a STRICT notice? > Options here are a notice whenever a property is defined in a trait, or > whenever properties are silently merged. > I would prefer they be definable within traits and merged into classes, otherwise traits will not have the chance to be self-contained entities of reusable logic. Also, I think merging them in is consistent with the treatment given to methods as they pertain to traits. As I'm sure you know: Regarding visibility modifiers, why not carry them over from the trait directly, private in the trait definition results in private in the class definition. Lastly, I'm not sure why you would want to discourage this usage, I would plan on adding properties in traits myself. -nathan --001636c5a5eb8aba7c049726ba5b--