Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28679 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 51729 invoked by uid 1010); 5 Apr 2007 03:38:39 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 51714 invoked from network); 5 Apr 2007 03:38:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Apr 2007 03:38:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=diogin@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=diogin@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.132.240 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.132.240 an-out-0708.google.com Received: from [209.85.132.240] ([209.85.132.240:16989] helo=an-out-0708.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FB/AA-27269-D3F64164 for ; Wed, 04 Apr 2007 23:38:38 -0400 Received: by an-out-0708.google.com with SMTP id c28so564931ana for ; Wed, 04 Apr 2007 20:38:35 -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:in-reply-to:mime-version:content-type:references; b=G39wmvI0VD3CGZgjpTnj76Y3UP/OG6xxPqRJzGHFqxtz0e3Q0hwLYBvf5PTj/xBxCvjtPjAumXx2kbPRoRszzHAegzUVyCchC7610joivtBLY2DbQnmZXn7XY4k+fOA7W0CjfU8bT5w3vBLfDb4xioeIoWmJ0gcLM6iYwWftCnQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=bPuPGE08b6sK06580LHVUStA70UnbvqZkPeH9jLvqM4kDKHBpkjmTolW0GIq70n6DKuIlaQEbZHN8CPmLi24jYfWwS2f5MkMwqlxla401tLHNfbiKhDE15/bdGciVlZCm+IpIog0wOLbu0JvLrFQ+tbLzaOqew1s53IzDmfayrQ= Received: by 10.100.133.9 with SMTP id g9mr1022041and.1175744314975; Wed, 04 Apr 2007 20:38:34 -0700 (PDT) Received: by 10.100.164.3 with HTTP; Wed, 4 Apr 2007 20:38:34 -0700 (PDT) Message-ID: Date: Thu, 5 Apr 2007 11:38:34 +0800 To: internals@lists.php.net In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_41735_24345378.1175744314930" References: Subject: Re: abstract static function From: diogin@gmail.com ("Jingcheng Zhang") ------=_Part_41735_24345378.1175744314930 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Sorry, I've forgotten the "extends" keywords in the example codes: 2007/4/5, Jingcheng Zhang : > > Hi internals, > I used to use abstract static function prior to php 5.2, because when > I consider static class as a singleton, I can use abstract static function > to delay the implementation of some methods to the derived classes. This > happens, for example, when I declare a parent dispatcher, and extend it into > two classes - action dispatcher and ajax dispatcher - and declare them > static as I want to keep them a singleton because they are just application > models, not domain models: > > abstract class Dispatcher { > abstract public static function dispatch(); > public static function exampleMethod() { > ... > } > } > final class ActionDispatcher { > public static function dispatch() { > parent::exampleMethod(); > // other code... > } > } > final class AjaxDispatcher { > public static function dispatch() { > parent::exampleMethod(); > // other code... > } > } > ?> > Unfortunately, since php 5.2, although it does still allow declaring > static methods in an interface, it simply generates a message when declaring > abstract static functions with error_reporting set to E_ALL | E_STRICT. > PHP is a dynamic language, not static as C++ and Java. So, why not > allow abstract static functions? It is also a good way to support singleton > natively. > Waiting for explanations. Thanks :) > > -- > Best regards, > Jingcheng Zhang > Room 304, Dormitory 26 of Yuquan Campus, Zhejiang University > P.R.China -- Best regards, Jingcheng Zhang Room 304, Dormitory 26 of Yuquan Campus, Zhejiang University P.R.China ------=_Part_41735_24345378.1175744314930--