Hey all (Filipe),
This was brought up in the thread "New dereferencing syntaxes in 5.4".
I too think this would be beneficial:
$value = ($obj = new Foo)->produceAValue();
but the current parser (branch 5.4) doesn't have a rule for this. I've
attached a quick/working patch, but I don't fully understand the
ramifications of such a patch.
Can someone explain the drawbacks of increasing the "%expect n" for me?
Would this many s/r require/benefit from a new expression grouping?
More to the point, can we have this small change for 5.4?
Thanks in advance.
-ralph
diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y
index a0c671b..f777b36 100644
--- a/Zend/zend_language_parser.y
+++ b/Zend/zend_language_parser.y
@@ -50,7 +50,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
%}
%pure_parser
-%expect 3
+%expect 4
%token END 0 "end of file"
%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
@@ -772,6 +772,7 @@ expr_without_variable:
| expr T_INSTANCEOF class_name_reference {
zend_do_instanceof(&$$, &$1, &$3, 0 TSRMLS_CC); }
| '(' expr ')' { $$ = $2; }
| new_expr { $$ = $1; }
+ | '(' variable '=' new_expr ')' {
zend_check_writable_variable(&$2); zend_do_assign(&$$, &$2, &$4 TSRMLS_CC); }
instance_call { $$ = $7; }
| '(' new_expr ')' { $$ = $2; } instance_call { $$ = $5; }
| expr '?' { zend_do_begin_qm_op(&$1, &$2 TSRMLS_CC); }
expr ':' { zend_do_qm_true(&$4, &$2, &$5 TSRMLS_CC); }
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php