@@ -9,12 +9,23 @@ This project is a JavaScript based [unparser](https://en.wikipedia.org/wiki/Unpa
9
9
It aims to produce code that uses the style format recommended by PSR-1 and PSR-2.
10
10
11
11
It's at an early development stage, but it is already able to generate code for most of the produced AST.
12
- It has no dependencies.
12
+
13
+ It has __ no dependencies__ .
13
14
14
15
## How to use
15
16
16
17
``` javascript
17
18
var unparse = require (' php-unparser' );
19
+
20
+ var options = {
21
+ indent: true ,
22
+ dontUseWhitespaces: false ,
23
+ shortArray: true ,
24
+ bracketsNewLine: true ,
25
+ forceNamespaceBrackets: false ,
26
+ collapseEmptyLines: true
27
+ };
28
+
18
29
var ast = {
19
30
" kind" : " program" ,
20
31
" children" : [
@@ -32,8 +43,21 @@ var ast = {
32
43
" errors" : []
33
44
};
34
45
35
- console .log (unparse (ast)); // Will output -> echo "hello world";
46
+ // Will output -> echo "hello world";
47
+ console .log (unparse (ast, options));
36
48
```
49
+
50
+ ## Options
51
+
52
+ | option | value | default | description |
53
+ | ------------------------| ---------| ----------| -------------|
54
+ | indent | string | | The indentation size, default is four white spaces. |
55
+ | dontUseWhitespaces | boolean | ` false ` | If enabled removes all the whitespaces between stuff. |
56
+ | shortArray | boolean | ` false ` | If enabled write arrays in short array syntax enabled since PHP 5.4.0 |
57
+ | bracketsNewLine | boolean | ` true ` | If enabled will put brackets on new line. |
58
+ | forceNamespaceBrackets | boolean | ` false ` | Force the namespace bracketed syntax (_ recommended for combining namespaces_ ) |
59
+ | collapseEmptyLines | boolean | ` true ` | If enabled it will remove all empty lines between sections and properties. |
60
+
37
61
## Demo
38
62
39
63
[ See it working] ( https://chris-l.github.io/php-unparser/ )
0 commit comments