Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51647 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59700 invoked from network); 9 Mar 2011 18:23:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2011 18:23:39 -0000 Authentication-Results: pb1.pair.com header.from=chadfulton@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=chadfulton@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.210.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: chadfulton@gmail.com X-Host-Fingerprint: 209.85.210.170 mail-iy0-f170.google.com Received: from [209.85.210.170] ([209.85.210.170:43098] helo=mail-iy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/83-40157-AA5C77D4 for ; Wed, 09 Mar 2011 13:23:38 -0500 Received: by iyb12 with SMTP id 12so830747iyb.29 for ; Wed, 09 Mar 2011 10:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=c8FsIvf+YFjCodGp44a7/Hqvf39knUYMA5Lq7d49fwg=; b=h2PdlSUAYlYMcW5HFlN5CSPZBQs4Cy6HvEeUMSzbFTtFxrbnqlGkAKzgr4YCSot1Yr PJr8CUQIwvclEin79wlQohpAbKG5nyW6Mlg9HniKZPAXSPI6ALLzizMLMp3ju3BUmJRY A5ksjgZgVR04Wc0xhdUsTGJzmj6a5EPQbudC8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=Vz+st5XXiQd7XZKGnejV65aVq0lhH8HeOIH4o15UTTQ1CrM5l5p2kz9HNf3iXVBlbi RCQ30aepeA8J5RZtx/E2VsplJTwwDVUw4lJfh5BeVev5pAHU+DAF4BgPholZhK2gCn1c h2H2lUe3RThkzY4iWBXxQcYKpxMHNJxy+hy2w= Received: by 10.231.112.216 with SMTP id x24mr5292579ibp.56.1299695016151; Wed, 09 Mar 2011 10:23:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.11.131 with HTTP; Wed, 9 Mar 2011 10:23:16 -0800 (PST) In-Reply-To: <8423995CEEEA844CB2F964B14BCA94CD043AC586@PRODEXCHANGE02.ilchildcare.org> References: <8423995CEEEA844CB2F964B14BCA94CD043ABC80@PRODEXCHANGE02.ilchildcare.org> <8423995CEEEA844CB2F964B14BCA94CD043AC586@PRODEXCHANGE02.ilchildcare.org> Date: Wed, 9 Mar 2011 10:23:16 -0800 Message-ID: To: Jarrod Nettles Cc: Hannes Landeholm , "internals@lists.php.net" , "james.butler@edigitalresearch.com" Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Class Access Modifiers From: chadfulton@gmail.com (Chad Fulton) Hello, On Wed, Mar 9, 2011 at 10:02 AM, Jarrod Nettles wrot= e: > Interesting question. My gut tells me not (as does three years of C# expe= rience). I=92m sure that everyone will have a different opinion on this but= to me it seems taboo that a child class override the visibility of the par= ent class. For example, PHP currently does not allow you to override a meth= od with a lower or higher visibility than the parent =96 I can=92t go from = protected to public or vice versa. Visibility must be maintained throughout= the class hierarchy. > Actually, class properties and methods can have a higher visibility than their parents, just not a lower one. E.g.: You get the following error: Fatal error: Access level to foobar::bar() must be public (as in class baz) in ... ------- That said, I wouldn't think that visibility modifiers on classes need to follow the same pattern. In the case of properties and methods, I think the rationale is that child classes should be compatible from an interface standpoint with their parents. That same logic may not transfer to class visibility modifiers. I am certainly no expert, but I'm curious what the use case is for class visibility modifiers? On Wed, Mar 9, 2011 at 7:11 AM, Hannes Landeholm wrot= e: > Currently I'm forced to use huge internal classes for my framework becaus= e dividing them into smaller classes would expose internal behavior to the "outside"... the application layer. > This doesn't necessarily make sense to me. Isn't it the end-developer's problem if they start instantiating classes in weird ways? It doesn't seem the same as having a private method, since in that case the end-developer presumably already has an object instance, and you want to guide them to the correct interface for interacting with it, whereas in an application, one would think that the end-developer wouldn't simply be instantiating classes by themselves all over the place. Chad