Skip to content

Commit 4c45a17

Browse files
committed
glayzzle#147 : introduce the binary cast (same as string)
1 parent cf6dcf8 commit 4c45a17

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/parser/expr.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,10 @@ module.exports = {
252252
return this.node("cast")("float", this.next().read_expr());
253253

254254
case this.tok.T_STRING_CAST:
255-
return this.node("cast")("string", this.next().read_expr());
255+
return this.node("cast")(
256+
this.text() === "(binary)" ? "binary" : "string",
257+
this.next().read_expr()
258+
);
256259

257260
case this.tok.T_ARRAY_CAST:
258261
return this.node("cast")("array", this.next().read_expr());

test/snapshot/__snapshots__/expr.test.js.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,16 @@ Program {
558558
"name": "var",
559559
},
560560
},
561+
Cast {
562+
"kind": "cast",
563+
"type": "binary",
564+
"what": Variable {
565+
"byref": false,
566+
"curly": false,
567+
"kind": "variable",
568+
"name": "var",
569+
},
570+
},
561571
Cast {
562572
"kind": "cast",
563573
"type": "array",

test/snapshot/expr.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ describe("Test expressions", function() {
117117
(double)$var;
118118
(real)$var;
119119
(string)$var;
120+
(binary)$var;
120121
(array)$var;
121122
(object)$var;
122123
(unset)$var;

0 commit comments

Comments
 (0)