From 42cc191c413727aed32118b82cfe3c75f05a482c Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Fri, 2 Nov 2012 14:26:23 +0800 Subject: [PATCH] Implemented instance invoke --- Zend/tests/instance_invoke_001.phpt | 31 +++++++++++++++++++++++++++++ Zend/tests/instance_invoke_002.phpt | 13 ++++++++++++ Zend/tests/instance_invoke_003.phpt | 27 +++++++++++++++++++++++++ Zend/zend_language_parser.y | 2 ++ 4 files changed, 73 insertions(+) create mode 100644 Zend/tests/instance_invoke_001.phpt create mode 100644 Zend/tests/instance_invoke_002.phpt create mode 100644 Zend/tests/instance_invoke_003.phpt diff --git a/Zend/tests/instance_invoke_001.phpt b/Zend/tests/instance_invoke_001.phpt new file mode 100644 index 000000000000..2f2c8f3c4da7 --- /dev/null +++ b/Zend/tests/instance_invoke_001.phpt @@ -0,0 +1,31 @@ +--TEST-- +Instance invoke +--FILE-- +dummy(); +var_dump((new Foo())->var); +var_dump((new Foo())->noexists); + +--EXPECT-- +string(10) "Foo::dummy" +string(3) "foo" +string(8) "noexists" diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y index c1514c5d783c..115e09f498de 100644 --- a/Zend/zend_language_parser.y +++ b/Zend/zend_language_parser.y @@ -727,6 +727,8 @@ instance_call: /* empty */ { $$ = $0; } | { zend_do_push_object(&$0 TSRMLS_CC); zend_do_begin_variable_parse(TSRMLS_C); } chaining_instance_call { zend_do_pop_object(&$$ TSRMLS_CC); zend_do_end_variable_parse(&$2, BP_VAR_R, 0 TSRMLS_CC); } + | { zend_do_begin_dynamic_function_call(&$0, 0 TSRMLS_CC); } + function_call_parameter_list { zend_do_end_function_call(&$0, &$$, &$2, 0, 1 TSRMLS_CC); zend_do_extended_fcall_end(TSRMLS_C); } instance_call { $$ = $4; } ; new_expr: