Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38561 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33459 invoked from network); 24 Jun 2008 05:07:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Jun 2008 05:07:44 -0000 Authentication-Results: pb1.pair.com smtp.mail=indeyets@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=indeyets@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.132.251 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: indeyets@gmail.com X-Host-Fingerprint: 209.85.132.251 an-out-0708.google.com Received: from [209.85.132.251] ([209.85.132.251:40137] helo=an-out-0708.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/75-32235-C1180684 for ; Tue, 24 Jun 2008 01:07:41 -0400 Received: by an-out-0708.google.com with SMTP id c14so581917anc.1 for ; Mon, 23 Jun 2008 22:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=M3TmBeS9A/LzoHg6WRGXlv26/yVwxMQeTF9oByKxxM0=; b=xfxGAxCqWVoA8lyJV/3AbZzaOqLcS8osGQHRf9lveHHTTWUDkaK9GRYhmqPHTOlWD6 9StC5eBwgQKY1nOIjf+aWHBuQgxNkseIL6gXoFI4RFLUrcSrPTpcmTQffFoOp6+ygu9S pm33fSEs5WfNTqlzI0e0GkRt0WbF/7Mde3t9c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=cxfYINx7G80vHw8JxW2ejQX8+y1ocMJJhwMFMXp9Gz9S0HnGvukXy94+c64d9ZXDPT XpIMKXtY4Yiu3aOx26ijXE9EoKQd7czMVs+ZWNnZKa7DOV9oYHO078Li+9c83Oa4zxnF mTiIiI1/60Rxn4YhygMRM9tBsIR8/m8dIV4uA= Received: by 10.100.194.5 with SMTP id r5mr14981786anf.2.1214284057886; Mon, 23 Jun 2008 22:07:37 -0700 (PDT) Received: by 10.100.91.3 with HTTP; Mon, 23 Jun 2008 22:07:37 -0700 (PDT) Message-ID: Date: Tue, 24 Jun 2008 09:07:37 +0400 To: "Stanislav Malyshev" Cc: "Etienne Kneuss" , "PHP internals" In-Reply-To: <485FDBE2.6020409@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <485C5081.1050609@zend.com> <485FDBE2.6020409@zend.com> Subject: Re: [PHP-DEV] LSB forward_static_call() From: indeyets@gmail.com ("Alexey Zakhlestin") On 6/23/08, Stanislav Malyshev wrote: > Hi! > > > > why would anyone need that? > > > > To use function that does use static without dependence on in which context > if was called (or, explaining it other way, when your chain of inheritance > serves multiple purposes): > > class ActiveRecord { > static function getRow($condition) { > $table = new Table(get_called_class()); > return $table->find($condition); > } > } > > class Users extends ActiveRecord { > } > > class DepartmentUsers extends Users { > static function find($user) { > if(self::user_in_department($user)) { > return parent::getRow("user=$user"); > } > return false; > } > } > > $user = DepartmentUsers::find("bob"); > > Now in this case if your way is implemented, ActiveRecord would try to find > table for DepartmentUsers, which probably does not exist. You would have to > name Users by name there to do what this code wants to do, which leads us > back to "why we have parent:: at all" argument. in my ActiveRecord, table for DepartmentUsers would actually exist ;) > > "parent" is related to inheritance and it is logical, that it retains > > call-chain. > > > > It is "logical" if you look at it with the narrow point of view of what you > need for your particular application. However, there are other use cases. > Automatic forwarding may become very awkward if you have multiple levels of > inheritance not all of them used for the same thing. I am just looking for consistency. I am expecting get_called_class() to work as a static analog of get_class(this) -- Alexey Zakhlestin http://blog.milkfarmsoft.com/