Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:44001 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96570 invoked from network); 16 May 2009 06:03:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 May 2009 06:03:35 -0000 Authentication-Results: pb1.pair.com header.from=diogin@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=diogin@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.222 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: diogin@gmail.com X-Host-Fingerprint: 209.85.217.222 mail-gx0-f222.google.com Received: from [209.85.217.222] ([209.85.217.222:54760] helo=mail-gx0-f222.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C6/72-12138-6375E0A4 for ; Sat, 16 May 2009 02:03:35 -0400 Received: by gxk22 with SMTP id 22so2451225gxk.23 for ; Fri, 15 May 2009 23:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=2neDgZ137N/QifUMj4M025TI+UBPsWO2WULB/3wHmZA=; b=c6Pq/fiyLDqcpr5Bpn9wFnypdmJP5iQJpsa7UmRIFWwBZ1mpeq1l37AVREVIGgKk6y z62K8KhQw8/RRwoJILJbTwynwb57le7D8zAnbai45ioViOQpBGUCEJPm6w5kWjzK7KMn dRFoTGV9mbmH37+e8/WkJCRm41DpwjqOrep80= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=D2Ur5pw9Yoi5boh4wXPylp54ITJ4y0twrtLSLZVrScdCjlYeSYusJt+UIPEXS8yXmi tciSyUfszpiFi27zp83Anwa6GAp4Q8unmWIJtyXIpwR/Vbm/qZzHjq5pb0Unly4QHAoR jf2aJ2GrPOZsQevMc0skskJ5jh4mqqDz0eTLw= MIME-Version: 1.0 Received: by 10.151.124.4 with SMTP id b4mr7646170ybn.232.1242453812426; Fri, 15 May 2009 23:03:32 -0700 (PDT) Date: Sat, 16 May 2009 14:03:32 +0800 Message-ID: To: php-dev Content-Type: multipart/alternative; boundary=001e680f116023b7da046a01525b Subject: Suggestion on static field inheritance From: diogin@gmail.com (Jingcheng Zhang) --001e680f116023b7da046a01525b Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello all, Maybe I have not found its detailed description on PHP's official manual, but PHP does allow static field inheritance. However there is a little difference between dynamic field inheritance and static field inheritance, as the following codes shows: name = $name; } public $name = 'a'; } class dynamic_c extends dynamic_a {} class dynamic_d extends dynamic_a {} $a = new dynamic_a(); $c = new dynamic_c(); $d = new dynamic_d(); echo $a->name; // a $c->change('c'); echo $a->name; // a $d->change('d'); echo $a->name; // a ?> The result of static inheritance test can be meaningful on some way(especially on class-based programming perspective), but when considering the static class as "object" in prototype-based programming(which I doubt is some people's favourite who comes from prototype-based OOP community), this result can be confusing. On JavaScript, this example can be: This looks more meaningful. So my suggestion is, could PHP's static inheritance rule follow the dynamic inheritance rule ( $this on dynamic, or prototype delegation on JavaScript) ? Thanks :-) -- Best regards, Jingcheng Zhang P.R.China --001e680f116023b7da046a01525b--