Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34968 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44143 invoked by uid 1010); 28 Jan 2008 17:37:31 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 44128 invoked from network); 28 Jan 2008 17:37:31 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Jan 2008 17:37:31 -0000 Authentication-Results: pb1.pair.com header.from=rewbs.soal@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=rewbs.soal@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.198.185 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rewbs.soal@gmail.com X-Host-Fingerprint: 209.85.198.185 rv-out-0910.google.com Received: from [209.85.198.185] ([209.85.198.185:2763] helo=rv-out-0910.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/33-25507-9D21E974 for ; Mon, 28 Jan 2008 12:37:31 -0500 Received: by rv-out-0910.google.com with SMTP id k15so1426943rvb.23 for ; Mon, 28 Jan 2008 09:37:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=vZltkTERzhP3DlJrOTqXZV/F2Z8QVbau46N5vTi7CSc=; b=A2HdCxOxst8mMUUwO8WIuCCV+EF6rpyFCETaue7p4FJT9TPE/SNCgn2KAz7zi44ezk+kPBKwRYo/MjcBywyLavSRwEaydIzmQLfNVKQ9NRHE98vjiWiYmsY52wlorKem7P0etdeVDY7eVnBuzkrGzfx5fUZ6WQT09PLmUCNMvx4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=vCoh2L3gIRY+mNlgFpPah1PtBrsZEVVsIaZDnT2lOwC1jmLcZ/Ol75g8WZgi9F4mHtmyWsxnbV2aSMGWU02heQlLnfdkqkR25aV2YHYFTx4TinM604uXhuVS3YvoTw0GbDx5DeVStT4PTjI8ncFxHZtfEDTh0nP+SACoD0xUomA= Received: by 10.141.152.8 with SMTP id e8mr3631180rvo.19.1201541845176; Mon, 28 Jan 2008 09:37:25 -0800 (PST) Received: by 10.65.250.2 with HTTP; Mon, 28 Jan 2008 09:37:25 -0800 (PST) Message-ID: <5a8807d10801280937j11c65623l7dca63aebec7cf1a@mail.gmail.com> Date: Mon, 28 Jan 2008 17:37:25 +0000 Reply-To: robin@soal.org To: "Marcus Boerger" , internals@lists.php.net, "Jochem Maas" In-Reply-To: <868592137.20080128174926@marcus-boerger.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5a8807d10801280520u7f8c7a9o8d2ab2efaa9c7644@mail.gmail.com> <1109819085.20080128151237@marcus-boerger.de> <5a8807d10801280718p6d52f689s3a13c4d8c6521a3f@mail.gmail.com> <868592137.20080128174926@marcus-boerger.de> Subject: Re: [PHP-DEV] Protected static props redeclared as public share value across classes From: rewbs.soal@gmail.com ("Robin Fernandes") Marcus, Thanks for looking in more detail. > I checked it out in more detail and it is indeed broken as in it is not > consistent: > [marcus@zaphod PHP_5_3]$ php -r 'class A { protected static $p=1; } class B extends A { protected static $p=2; } ReflectionClass::Export("B");' > -> works == 2 properties > -> but should fail because of changed value > > [marcus@zaphod PHP_5_3]$ php -r 'class A { protected static $p=1; } class B extends A { public static $p=2; } ReflectionClass::Export("B");' > Fatal error: Cannot change initial value of property static protected A::$p in class B in Command line code on line 1 > > [marcus@zaphod PHP_5_3]$ php -r 'class A { public static $p=1; } class B extends A { protected static $p=2; } ReflectionClass::Export("B");' > Fatal error: Access level to B::$p must be public (as in class A) in Command line code on line 1 > > [marcus@zaphod PHP_5_3]$ php -r 'class A { public static $p=1; } class B extends A { public static $p=2; } ReflectionClass::Export("B");' > -> works == 2 properties > -> but should fail becasue of changed value > > So we need to fix this. > I agree with Jochem: I'm not fully confident about the statement 'but should fail because of changed value', for two reasons: 1. The issues doesn't stop with default values. Consider the case below. If we were go with your suggested fix, the parent and child class "feel" like they have separate properties, but in fact point to the same value. It is imho more natural for the two classes to genuinely have separate values. Another alternative would be to forbid redeclaring statics with the same visibility modifier altogther (default value or no default value), though I would personally be less happy with that. 2. The suggested fix would create an inconsistency with class constants, where it is legal to shadow inherited values: Many thanks, Robin