Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29820 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 27878 invoked by uid 1010); 26 May 2007 22:49:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 27863 invoked from network); 26 May 2007 22:49:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2007 22:49:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=dohpaz@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dohpaz@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 66.249.92.173 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: dohpaz@gmail.com X-Host-Fingerprint: 66.249.92.173 ug-out-1314.google.com Linux 2.4/2.6 Received: from [66.249.92.173] ([66.249.92.173:28943] helo=ug-out-1314.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/57-49291-B59B8564 for ; Sat, 26 May 2007 18:49:01 -0400 Received: by ug-out-1314.google.com with SMTP id m2so1087500uge for ; Sat, 26 May 2007 15:48:57 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; b=JT8/NYZNzpH/GBC/5E9oSnKgFdYrbKW41cexRy3hWdR32FCTOBAoyeiCb/PJ/uH0DjvV8IS9RIl54vRaAzhvdkBWIeNr5OYBxeP3yjacwem+oAhePzX/NlzR1/uTB5UFoCroTU4rJsgzHojzNHv3MyGOXM0IzOl6W88Jmx3AVVc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=lzvCp71U87MAabVWpPXXi5NtViio1bhSGwJMkBmOYp4z/1qfDC7Gi3MJIjlnW0+hc4ZFjPmKD2IMScw9cbTn32mvXll/Mhee8G5c9SZh6PD4lTitwc9RN6naM1FxRWhOIza3tjhW16OOTPTJOWJIPFf+JrduxthFsQf18/K9YBY= Received: by 10.78.193.19 with SMTP id q19mr1304008huf.1180219736929; Sat, 26 May 2007 15:48:56 -0700 (PDT) Received: by 10.78.149.16 with HTTP; Sat, 26 May 2007 15:48:56 -0700 (PDT) Message-ID: Date: Sat, 26 May 2007 18:48:56 -0400 To: internals@lists.php.net MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_81955_828231.1180219736898" Subject: late static binding From: dohpaz@gmail.com ("Ken Stanley") ------=_Part_81955_828231.1180219736898 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all! I've been researching the current status of late static binding, and I came across this mailing list with a few topics on this subject. After doing the reading, I had a couple of questions that maybe one of the experienced parties involved could help clear up for me. Basically, I am wondering if anybody has tossed around the idea of having a scope of child::, just like there is one of parent:: (for the class that is inherited from) and self:: (the current class). I understand that the idea has been discussed about this:: or static::, but those two suggestions -- as fine as they are -- just seem counter intuitive. this has always been used in the same context as self::, but for instantiated objects, and static:: seems redundant (at least to me). Is there a reason why this:: would be preferred over child::? My second question on this topic would be how hard would it be to create a child scope in the Zend Engine? Since I am not a very experienced C programmer, this may be a naive question, but if Zend is smart enough to know who the inherited class object is, could it be much more difficult to know who did the inheriting? I mainly wanted to just add my Two Cents to the discussion, because as I get more and more into using PHP5 for OO programming, I am finding it more important to have late static binding. And, since I've seen the request made for examples of real-world use-cases, I am trying to build a set of classes that would allow me to work with the super globals without actually directly touching them. If we had something like a child:: scope, then I could write code that looked like this: class MyGlobals { static public function get($name) { // Each child would implement their own version of filter // that would handle the type of data that it has. child::filter(child::$global[$name]; // Do common stuff here before returning value } } class FilesGlobal extends MyGlobals { // This is so the parent class will know where to look for the information we need. Each class would have this declaration. static protected $global = $_FILES; static protected filter($value) { // Do file-related filtering here (i.e., validate filename is valid, exists, etc) or throw an exception // on failure. } } Instead, I have to write 9 separate classes, with each of the classes having all the same functions that are written almost exactly the same. So, for example, if I have 100 lines of code in one class, my overall set of classes would contain almost 800 lines of duplicate code. I hope this illustrates the appeal for this feature. It is a maintenance nightmare! :) I know it has been said by some that this functionality is rare, but I would like to say that the functionality was just never needed until recently. There are many cases that I can think of that this would be helpful, and if need be, I would be more than happy to write more examples. I think, however, that the above example shows a good situation for the parent class to be able to see the child class. Regardless of the direction taken with this issue, I would like thank all of the developers who have made PHP so great. :) - Ken -- It looked like something resembling white marble, which was probably what it was: something resembling white marble. -- Douglas Adams, "The Hitchhikers Guide to the Galaxy" ------=_Part_81955_828231.1180219736898--