mirror of
https://github.com/php/php-src.git
synced 2025-01-27 06:03:45 +08:00
* Use to_string() instead of __print()
* Support boolean casts ((bool) and (boolean))
This commit is contained in:
parent
99fd17df63
commit
963a004481
@ -58,7 +58,7 @@
|
||||
%left T_SL T_SR
|
||||
%left '+' '-' '.'
|
||||
%left '*' '/' '%'
|
||||
%right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST '@'
|
||||
%right '!' '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST '@'
|
||||
%right '['
|
||||
%nonassoc T_NEW
|
||||
%token T_EXIT
|
||||
@ -426,6 +426,7 @@ expr_without_variable:
|
||||
| T_STRING_CAST expr { do_cast(&$$, &$2, IS_STRING CLS_CC); }
|
||||
| T_ARRAY_CAST expr { do_cast(&$$, &$2, IS_ARRAY CLS_CC); }
|
||||
| T_OBJECT_CAST expr { do_cast(&$$, &$2, IS_OBJECT CLS_CC); }
|
||||
| T_BOOL_CAST expr { do_cast(&$$, &$2, IS_BOOL CLS_CC); }
|
||||
| T_EXIT exit_expr { do_exit(&$$, &$2 CLS_CC); }
|
||||
| '@' { do_begin_silence(&$1 CLS_CC); } expr { do_end_silence(&$1 CLS_CC); $$ = $3; }
|
||||
| scalar { $$ = $1; }
|
||||
|
@ -737,6 +737,10 @@ ESCAPED_AND_WHITESPACE [\n\t\r #'.:;,()|^&+-/*=%!~<>?@]+
|
||||
return T_OBJECT_CAST;
|
||||
}
|
||||
|
||||
<ST_IN_SCRIPTING>"("{TABS_AND_SPACES}("bool"|"boolean"){TABS_AND_SPACES}")" {
|
||||
return T_BOOL_CAST;
|
||||
}
|
||||
|
||||
<ST_IN_SCRIPTING>"eval" {
|
||||
return T_EVAL;
|
||||
}
|
||||
|
@ -1667,6 +1667,9 @@ send_by_ref:
|
||||
zendi_zval_copy_ctor(*result);
|
||||
}
|
||||
switch (opline->op2.u.constant.type) {
|
||||
case IS_BOOL:
|
||||
convert_to_boolean(result);
|
||||
break;
|
||||
case IS_LONG:
|
||||
convert_to_long(result);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user