Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:54248 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 84307 invoked from network); 29 Jul 2011 09:10:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Jul 2011 09:10:36 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:40389] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/31-07983-CE8723E4 for ; Fri, 29 Jul 2011 05:10:04 -0400 Received: by vxi39 with SMTP id 39so2841078vxi.29 for ; Fri, 29 Jul 2011 02:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=YAobLSyICoeTaRQiLxO7CAECEG3j+FLic2YdDtrWbKA=; b=v78DEb8ErgSXQ4hIdZNmViKtWUl1goa6nZaF4jiPDOO5JkboeBB793bLtBt7WQ2cdR Twl6XWFSwUgJqnQK414KY3m7u7oKlokXld0PzqZ85bluAFfYdTGDLTIVKCDEwSFm+YK1 RBLXxCsTFaLxuZcIzTktoAJd6G+lbOFcwlmoE= MIME-Version: 1.0 Received: by 10.52.179.40 with SMTP id dd8mr1066002vdc.208.1311930601700; Fri, 29 Jul 2011 02:10:01 -0700 (PDT) Sender: laruence@gmail.com Received: by 10.220.161.130 with HTTP; Fri, 29 Jul 2011 02:10:01 -0700 (PDT) In-Reply-To: References: Date: Fri, 29 Jul 2011 17:10:01 +0800 X-Google-Sender-Auth: CUDYgqTiWpRlYHvtVCzToDdNrvU Message-ID: To: Etienne Kneuss Cc: PHP Internals , Felipe Pena , Pierre Joye , =?UTF-8?Q?Johannes_Schl=C3=BCter?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [Bug #55311] Static methods invoke __call when called from within class From: laruence@php.net (Laruence) Hi: 2011/7/29 Etienne Kneuss : > Hi, > > On Fri, Jul 29, 2011 at 05:37, Laruence wrote: >> Hi: >> =C2=A0 =C2=A0 about #55311.https://bugs.php.net/bug.php?id=3D55311 >> >> =C2=A0 =C2=A0 I found it maybe for some reason, that somebody change the >> if/elseif sequence to make this bug. >> >> =C2=A0 =C2=A0 but I am not sure about why he do this, =C2=A0so I refer t= o maillist, =C2=A0any idea? > > This is not a bug. > > If you call a method using the Foo::bar() syntax, you don't > necessarily get a static call. > > A static call is made if either: > > 1) the target method is declared as static > 2) There is no compatible object context at the time of the call. I was wondering does this is well-documented? since when? obviously, it is BC break to PHP 5.3.3. in PHP 5.3.3 __staticCall is in the front of the if/elseif statements. so I was very interesting to know why this was changed thanks, ;) > > In this case, it is not a static call, as the method is undeclared > (hence cannot be declared as static) and you do have a compatible > object context. So __call is used, not __callstatic. > > Best, > >> >> =C2=A0 =C2=A0Index: Zend/zend_object_handlers.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- Zend/zend_object_handlers.c (revision 313905) >> +++ Zend/zend_object_handlers.c (working copy) >> @@ -988,13 +988,13 @@ >> =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!fbc && zend_hash_find(&ce->function_tabl= e, lc_function_name, >> function_name_strlen+1, (void **) &fbc)=3D=3DFAILURE) { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0efree(lc_function= _name); >> >> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (ce->__call && >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (ce->__callstatic)= { >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 return zend_get_user_callstatic_function(ce, function_name_strval, >> function_name_strlen); >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } else if (ce->__call= && >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0EG(= This) && >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Z_O= BJ_HT_P(EG(This))->get_class_entry && >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ins= tanceof_function(Z_OBJCE_P(EG(This)), ce TSRMLS_CC)) { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0return zend_get_user_call_function(ce, function_name_strval, >> function_name_strlen); >> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } else if (ce->__call= static) { >> - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 return zend_get_user_callstatic_function(ce, function_name_strval, >> function_name_strlen); >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} else { >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0return NULL; >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >> -- >> Laruence =C2=A0Xinchen Hui >> http://www.laruence.com/ >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > > -- > Etienne Kneuss > http://www.colder.ch > --=20 Laruence =C2=A0Xinchen Hui http://www.laruence.com/