Skip to content

Commit 9706667

Browse files
committed
#37 - Add full support for object variable declaration
1 parent fd38e28 commit 9706667

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

parser/parser.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,10 @@ static void xx_ret_declare_statement(zval *ret, int type, zval *variables, xx_sc
10491049
parser_add_str(ret, "data-type", "bool");
10501050
break;
10511051

1052+
case XX_T_TYPE_OBJECT:
1053+
parser_add_str(ret, "data-type", "object");
1054+
break;
1055+
10521056
case XX_T_TYPE_STRING:
10531057
parser_add_str(ret, "data-type", "string");
10541058
break;
@@ -1073,10 +1077,6 @@ static void xx_ret_declare_statement(zval *ret, int type, zval *variables, xx_sc
10731077
parser_add_str(ret, "data-type", "mixed");
10741078
break;
10751079

1076-
case XX_T_TYPE_OBJECT:
1077-
parser_add_str(ret, "data-type", "object");
1078-
break;
1079-
10801080
default:
10811081
fprintf(stderr, "err 2?\n");
10821082
}

parser/zephir.lemon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,10 @@ xx_declare_statement(R) ::= TYPE_MIXED xx_declare_variable_list(L) DOTCOMMA . {
17411741
xx_ret_declare_statement(&R, XX_T_TYPE_MIXED, &L, status->scanner_state);
17421742
}
17431743

1744+
xx_declare_statement(R) ::= TYPE_OBJECT xx_declare_variable_list(L) DOTCOMMA . {
1745+
xx_ret_declare_statement(&R, XX_T_TYPE_OBJECT, &L, status->scanner_state);
1746+
}
1747+
17441748
xx_declare_variable_list(R) ::= xx_declare_variable_list(L) COMMA xx_declare_variable(V) . {
17451749
xx_ret_list(&R, &L, &V, status->scanner_state);
17461750
}

tests/base/declare.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function test() {
1919
string foo = "foobar";
2020
array foo = [10,20,30];
2121
var foo = 10;
22+
object obj = new stdClass;
2223
}
2324
ZEP;
2425

@@ -47,3 +48,4 @@ declare bool foo bool true
4748
declare string foo string foobar
4849
declare array foo array -
4950
declare variable foo int 10
51+
declare object obj new -

0 commit comments

Comments
 (0)