Skip to content

Commit fefbccf

Browse files
committed
glayzzle#46 add an encapsed node
1 parent b19eeb0 commit fefbccf

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/ast/encapsed.js

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*!
2+
* Copyright (C) 2017 Glayzzle (BSD3 License)
3+
* @authors https://github.com/glayzzle/php-parser/graphs/contributors
4+
* @url http://glayzzle.com
5+
*/
6+
7+
var Literal = require('./literal');
8+
var KIND = 'encapsed';
9+
10+
/**
11+
* Defines an encapsed string (contains expressions)
12+
* @constructor Encapsed
13+
* @extends {Literal}
14+
* @property {String} type - Defines the type of encapsed string (shell, heredoc, string)
15+
* @property {String|Null} label - The heredoc label, defined only when the type is heredoc
16+
*/
17+
var Encapsed = Literal.extends(function Encapsed(value, type, location) {
18+
Literal.apply(this, [KIND, value, location]);
19+
this.type = type;
20+
});
21+
22+
23+
/**
24+
* The node is a double quote string :
25+
* ```php
26+
* <?php
27+
* echo "hello $world";
28+
* ```
29+
* @constant {String} TYPE_STRING - `string`
30+
*/
31+
Encapsed.TYPE_STRING = 'string';
32+
33+
/**
34+
* The node is a shell execute string :
35+
* ```php
36+
* <?php
37+
* echo `ls -larth $path`;
38+
* ```
39+
* @constant {String} TYPE_SHELL - `shell`
40+
*/
41+
Encapsed.TYPE_SHELL = 'shell';
42+
43+
/**
44+
* The node is a shell execute string :
45+
* ```php
46+
* <?php
47+
* echo <<<STR
48+
* Hello $world
49+
* STR
50+
* ;
51+
* ```
52+
* @constant {String} TYPE_HEREDOC - `heredoc`
53+
*/
54+
Encapsed.TYPE_HEREDOC = 'heredoc';
55+
56+
module.exports = Encapsed;

0 commit comments

Comments
 (0)