Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:31338 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62600 invoked by uid 1010); 31 Jul 2007 11:57:34 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 62585 invoked from network); 31 Jul 2007 11:57:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Jul 2007 11:57:34 -0000 Authentication-Results: pb1.pair.com header.from=johannes@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 83.243.58.163 as permitted sender) X-PHP-List-Original-Sender: johannes@php.net X-Host-Fingerprint: 83.243.58.163 mail4.netbeat.de Received: from [83.243.58.163] ([83.243.58.163:51289] helo=mail4.netbeat.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/87-08908-AA32FA64 for ; Tue, 31 Jul 2007 07:57:32 -0400 Received: (qmail 24652 invoked by uid 507); 31 Jul 2007 11:57:26 -0000 Received: from unknown (HELO ?192.168.1.102?) (postmaster%schlueters.de@82.135.9.194) by mail4.netbeat.de with ESMTPA; 31 Jul 2007 11:57:26 -0000 To: Etienne Kneuss Cc: internals@lists.php.net, Ilia Alshanetsky In-Reply-To: <46AE49B3.2070100@php.net> References: <46AE49B3.2070100@php.net> Content-Type: text/plain Date: Tue, 31 Jul 2007 13:57:15 +0200 Message-ID: <1185883035.23889.31.camel@johannes.nop> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-1.fc7) Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Fix inconsistencies in OO calls From: johannes@php.net (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi Etienne, On Mon, 2007-07-30 at 22:27 +0200, Etienne Kneuss wrote: > Hello, > > Currently, those are allowed: > > new $classname; > classname::$methodname(); > > but those aren't: > > $classname::foo(); > $classname::CONST; > $classname::$member; > > Here is a patch for head that fixes those inconsistencies by extending > the language parser to support such syntax: thanks for this fix. Ilia, do you mind MFHing this fix before the next 5.2 release? Then I'd commit it within the next days. johannes > http://patches.colder.ch/Zend/dynamic_static_calls.patch?markup (patch > also attached) > > Regards > > plain text document attachment (dynamic_static_calls.patch) > Index: Zend/zend_language_parser.y > =================================================================== > RCS file: /repository/ZendEngine2/zend_language_parser.y,v > retrieving revision 1.186 > diff -u -p -r1.186 zend_language_parser.y > --- Zend/zend_language_parser.y 27 Jul 2007 09:04:12 -0000 1.186 > +++ Zend/zend_language_parser.y 30 Jul 2007 20:28:41 -0000 > @@ -649,6 +649,12 @@ function_call: > | fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } > function_call_parameter_list > ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} > + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' { zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } > + function_call_parameter_list > + ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} > + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } > + function_call_parameter_list > + ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} > | fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects '(' { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); zend_do_begin_class_member_function_call(&$1, &$3 TSRMLS_CC); } > function_call_parameter_list > ')' { zend_do_end_function_call(NULL, &$$, &$6, 1, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C);} > @@ -809,6 +815,11 @@ variable_without_objects: > > static_member: > fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member(&$$, &$1 TSRMLS_CC); } > + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM variable_without_objects { $$ = $3; zend_do_fetch_static_member(&$$, &$1 TSRMLS_CC); } > +; > + > +variable_class_name: > + reference_variable { zend_do_end_variable_parse(BP_VAR_R, 0 TSRMLS_CC); $$=$1;} > ; > > > @@ -935,6 +946,7 @@ isset_variables: > > class_constant: > fully_qualified_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT TSRMLS_CC); } > + | variable_class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { zend_do_fetch_constant(&$$, &$1, &$3, ZEND_RT TSRMLS_CC); } > ; > > %% > Index: tests/lang/041.phpt > =================================================================== > RCS file: tests/lang/041.phpt > diff -N tests/lang/041.phpt > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ tests/lang/041.phpt 30 Jul 2007 20:28:41 -0000 > @@ -0,0 +1,23 @@ > +--TEST-- > +Dynamic access of static members > +--FILE-- > + +class A { > + public static $b = 'foo'; > +} > + > +$classname = 'A'; > +$binaryClassname = b'A'; > +$wrongClassname = 'B'; > + > +echo $classname::$b."\n"; > +echo $binaryClassname::$b."\n"; > +echo $wrongClassname::$b."\n"; > + > +?> > +===DONE=== > +--EXPECTF-- > +foo > +foo > + > +Fatal error: Class 'B' not found in %s041.php on line %d > Index: tests/lang/042.phpt > =================================================================== > RCS file: tests/lang/042.phpt > diff -N tests/lang/042.phpt > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ tests/lang/042.phpt 30 Jul 2007 20:28:41 -0000 > @@ -0,0 +1,22 @@ > +--TEST-- > +Dynamic access of constants > +--FILE-- > + +class A { > + const B = 'foo'; > +} > + > +$classname = 'A'; > +$binaryClassname = b'A'; > +$wrongClassname = 'B'; > + > +echo $classname::B."\n"; > +echo $binaryClassname::B."\n"; > +echo $wrongClassname::B."\n"; > +?> > +===DONE=== > +--EXPECTF-- > +foo > +foo > + > +Fatal error: Class 'B' not found in %s042.php on line %d > Index: tests/lang/043.phpt > =================================================================== > RCS file: tests/lang/043.phpt > diff -N tests/lang/043.phpt > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ tests/lang/043.phpt 30 Jul 2007 20:28:41 -0000 > @@ -0,0 +1,22 @@ > +--TEST-- > +Dynamic call for static methods > +--FILE-- > + +class A { > + static function foo() { return 'foo'; } > +} > + > +$classname = 'A'; > +$binaryClassname = b'A'; > +$wrongClassname = 'B'; > + > +echo $classname::foo()."\n"; > +echo $binaryClassname::foo()."\n"; > +echo $wrongClassname::foo()."\n"; > +?> > +===DONE=== > +--EXPECTF-- > +foo > +foo > + > +Fatal error: Class 'B' not found in %s043.php on line %d > Index: tests/lang/044.phpt > =================================================================== > RCS file: tests/lang/044.phpt > diff -N tests/lang/044.phpt > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ tests/lang/044.phpt 30 Jul 2007 20:28:41 -0000 > @@ -0,0 +1,30 @@ > +--TEST-- > +Dynamic call for static methods dynamically named > +--FILE-- > + +class A { > + static function foo() { return 'foo'; } > +} > +$classname = 'A'; > +$binaryClassname = b'A'; > +$wrongClassname = 'B'; > + > +$methodname = 'foo'; > +$binaryMethodname = b'foo'; > + > +echo $classname::$methodname()."\n"; > +echo $classname::$binaryMethodname()."\n"; > + > +echo $binaryClassname::$methodname()."\n"; > +echo $binaryClassname::$binaryMethodname()."\n"; > + > +echo $wrongClassname::$binaryMethodname()."\n"; > +?> > +===DONE=== > +--EXPECTF-- > +foo > +foo > +foo > +foo > + > +Fatal error: Class 'B' not found in %s044.php on line %d > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php