Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:35062 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17628 invoked by uid 1010); 31 Jan 2008 20:48:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 17612 invoked from network); 31 Jan 2008 20:48:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jan 2008 20:48:44 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 204.11.219.139 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 204.11.219.139 mail.lerdorf.com Received: from [204.11.219.139] ([204.11.219.139:42859] helo=mail.lerdorf.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 61/29-07682-92432A74 for ; Thu, 31 Jan 2008 15:48:43 -0500 Received: from trainburn-lm.corp.yahoo.com (trainburn-lm.corp.yahoo.com [207.126.233.11]) (authenticated bits=0) by mail.lerdorf.com (8.14.2/8.14.2/Debian-2) with ESMTP id m0VKmZjM008189 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 31 Jan 2008 12:48:37 -0800 Message-ID: <47A23423.4060305@lerdorf.com> Date: Thu, 31 Jan 2008 12:48:35 -0800 User-Agent: Thunderbird 2.0.0.9 (Macintosh/20071031) MIME-Version: 1.0 To: Greg Beaver CC: Marcus Boerger , Scott MacVicar , php-dev References: <47A05612.4020505@php.net> <1462818236.20080130160605@marcus-boerger.de> <47A22593.1010709@php.net> In-Reply-To: <47A22593.1010709@php.net> X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV 0.92/5628/Thu Jan 31 08:48:19 2008 on colo.lerdorf.com X-Virus-Status: Clean Subject: Re: [PHP-DEV] BC break with callbacks in 5.3 From: rasmus@lerdorf.com (Rasmus Lerdorf) Greg Beaver wrote: > Marcus Boerger wrote: >> Hello Scott, >> >> actually it was a bug. We, sorry I, did not spot this in earlier versions. >> Now saying you rely on a bug in PHP 5 to be able to execute PHP 4 code >> simply does not work. > > Hi Marcus, > > How is forcing users to replace call_user_func(array('Classname', > 'func')) with eval('Classname::func') a good policy? > > When this example code: > > error_reporting(E_NOTICE|E_WARNING|E_ERROR); > class A { function B (){}} > A::B(); > ?> > > functions differently from this code: > > error_reporting(E_NOTICE|E_WARNING|E_ERROR); > class A { function B (){}} > call_user_func(array('A','B')); > ?> > > And in a minor version increment, this in fact introduces a bug, and > doesn't fix one. > > I think the fix may be to simply add retval=0 in > zend_is_callable_check_func() here: > > if ((check_flags & IS_CALLABLE_CHECK_IS_STATIC) != 0) { > retval = 0; > } else { > if (EG(This) && instanceof_function(Z_OBJCE_P(EG(This)), *ce_ptr > TSRMLS_CC)) { > *zobj_ptr_ptr = &EG(This); > zend_error(E_STRICT, "Non-static method %s::%s() cannot be called > statically, assuming $this from compatible context %s", (*ce_ptr)->name, > fptr->common.function_name, Z_OBJCE_P(EG(This))->name); > } else { > zend_error(E_STRICT, "Non-static method %s::%s() cannot be called > statically", (*ce_ptr)->name, fptr->common.function_name); > } > } > > basically what is happening is that E_STRICT makes the callback invalid, > which is not technically true - the callback is valid, just not strictly > correct. > > I can make a patch next week, if someone doesn't beat me to it. We need > a retval=0 in the inner else clause Yes, I agree that we need to be consistent here. error_reporting(E_ALL|E_STRICT); class foo { function bar() { echo "gah"; } } call_user_func('foo::bar'); foo::bar(); This needs to throw an E_STRICT in both cases. Right now we get an E_WARNING and the call doesn't work for the first, and an E_STRICT for the second. Having these behave differently makes no sense. And likewise, is_callable('foo::bar') should return true. -Rasmus