File tree Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Expand file tree Collapse file tree 3 files changed +18
-11
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,8 @@ var parser = function(lexer) {
86
86
this . tok . T_DIR ,
87
87
this . tok . T_NS_C ,
88
88
'"' ,
89
+ 'b"' ,
90
+ 'B"' ,
89
91
'-' ,
90
92
this . tok . T_NS_SEPARATOR
91
93
] ,
Original file line number Diff line number Diff line change @@ -65,11 +65,6 @@ module.exports = {
65
65
*/
66
66
, read_expr_item : function ( ) {
67
67
68
- if ( this . token === this . tok . T_STRING ) {
69
- var tokTxt = this . text ( ) ;
70
- if ( tokTxt === 'b' || tokTxt === 'B' ) this . token = this . tok . T_STRING_CAST ;
71
- }
72
-
73
68
switch ( this . token ) {
74
69
75
70
case '@' :
Original file line number Diff line number Diff line change @@ -37,28 +37,38 @@ module.exports = {
37
37
// TEXTS
38
38
case this . tok . T_CONSTANT_ENCAPSED_STRING :
39
39
var value = this . text ( ) ;
40
- value = value . substring ( 1 , value . length - 1 ) . replace (
40
+ var isBinCast = value [ 0 ] === 'b' || value [ 0 ] === 'B' ;
41
+ if ( isBinCast ) {
42
+ value = value . substring ( 2 , value . length - 1 ) ;
43
+ } else {
44
+ value = value . substring ( 1 , value . length - 1 ) ;
45
+ }
46
+ value = [ 'string' , value . replace (
41
47
/ \\ [ r n t v e f " ' \\ \$ ] / g,
42
48
function ( seq ) {
43
49
return specialChar [ seq ] ;
44
50
}
45
- ) ;
51
+ ) ] ;
52
+ if ( isBinCast ) {
53
+ value = [ 'cast' , 'binary' , value ] ;
54
+ }
46
55
this . next ( ) ;
47
56
if ( this . token === this . tok . T_DOUBLE_COLON ) {
48
57
// https://github.com/php/php-src/blob/master/Zend/zend_language_parser.y#L1151
49
- return this . read_static_getter (
50
- [ 'string' , value ]
51
- ) ;
58
+ return this . read_static_getter ( value ) ;
52
59
} else {
53
60
// dirrect string
54
- return [ 'string' , value ] ;
61
+ return value ;
55
62
}
56
63
case this . tok . T_START_HEREDOC :
57
64
return this . next ( ) . read_encapsed_string (
58
65
this . tok . T_END_HEREDOC
59
66
) ;
60
67
case '"' :
61
68
return this . next ( ) . read_encapsed_string ( '"' ) ;
69
+ case 'b"' :
70
+ case 'B"' :
71
+ return [ 'cast' , 'binary' , this . next ( ) . read_encapsed_string ( '"' ) ] ;
62
72
63
73
// NUMERIC
64
74
case '-' : // long
You can’t perform that action at this time.
0 commit comments