Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51018 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11304 invoked from network); 13 Dec 2010 13:13:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Dec 2010 13:13:46 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qw0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:61128] helo=mail-qw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/00-10983-80C160D4 for ; Mon, 13 Dec 2010 08:13:45 -0500 Received: by qwj8 with SMTP id 8so6336796qwj.29 for ; Mon, 13 Dec 2010 05:13:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:reply-to :in-reply-to:references:from:date:message-id:subject:to:cc :content-type:content-transfer-encoding; bh=QhC3FmOUNMx2XoTN2Ocy1BibS+bT4vx5Kq8HrNomSC0=; b=Tb8YnysVrThhEVzT00WrsdIGF7M2/NqosnzaG+ljqOqCI58CV5VftH6eygUIdwRMmA CoB1VbEYHqEOBA83QrSWmUg3BTluHPZSUsLz2ME0682udhX18MMK9r2Qz0N3NbECxY6k TKikJUAVAvjauhc5GUcToDfi+UMTZktLIuMPU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=tYTTsgC9W/UHNxmHdqLNIKV8SGlPtHQBgysW8AA0OaOMwHcd36GQdJfeSOBGX2VBmY zWnoNv4VeyO6LRrXS5CzsNGs4f7a27OqwlX/n5NH39ccm3GAOEv1KGrqpyxmIZrY/B+O 7cqJ8MKj7ICW7keRspvE/6JLKDBhFg4bhd4AQ= Received: by 10.229.184.13 with SMTP id ci13mr3696842qcb.253.1292246022452; Mon, 13 Dec 2010 05:13:42 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.100.130 with HTTP; Mon, 13 Dec 2010 05:13:22 -0800 (PST) Reply-To: RQuadling@googlemail.com In-Reply-To: <89C52156-CF92-4DDB-8BA4-4ABF6883512C@stefan-marr.de> References: <89C52156-CF92-4DDB-8BA4-4ABF6883512C@stefan-marr.de> Date: Mon, 13 Dec 2010 13:13:22 +0000 Message-ID: To: Stefan Marr Cc: "internals@lists.php.net Development" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Traits and Properties From: rquadling@gmail.com (Richard Quadling) On 11 December 2010 16:47, Stefan Marr wrote: > Hi: > > Traits do not provide any special provisioning for handling properties, e= specially, there is no language solution for handling colliding property na= mes. > 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 referenc= e to the property in the class. > > However, at the moment it is possible to define properties in a trait: > > trait Foo { > =C2=A0private $a; > =C2=A0public =C2=A0$foo; > } > > For the moment, that information is completely ignored, thus: > > class Bar { > =C2=A0use Foo; > } > property_exists('Bar', 'a') =3D=3D=3D 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 altoget= her. > That reduces a bit the possibility to have wrong expectations about prope= rties, 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 merg= e 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 whe= never properties are silently merged. > > > Comments very welcome. > > Thanks > Stefan From the rfc [1], "A Trait is similar to a class, but only intended to group functionality". I'm guessing that says it all. A trait has no properties. But. If properties are to be added to a trait, I think that should come as a further enhancement and let traits start out as "methods only". If a trait is properties, then also supporting constants and the other sort of set/get properties would provide a strong level of consistency. If I can put it in a class, I can put it in a trait. As visibility on the traits methods can be manipulated via the aliasing mechanism, so should any visibility to a property. Richard. [1] http://wiki.php.net/rfc/horizontalreuse --=20 Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY