Skip to content

Commit a695232

Browse files
committed
Merge branch 'b4dnewz-master'
2 parents f3da749 + 96082a7 commit a695232

27 files changed

+4074
-121
lines changed

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,23 @@ This project is a JavaScript based [unparser](https://en.wikipedia.org/wiki/Unpa
99
It aims to produce code that uses the style format recommended by PSR-1 and PSR-2.
1010

1111
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__.
1314

1415
## How to use
1516

1617
```javascript
1718
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+
1829
var ast = {
1930
"kind": "program",
2031
"children": [
@@ -32,8 +43,21 @@ var ast = {
3243
"errors": []
3344
};
3445

35-
console.log(unparse(ast)); // Will output -> echo "hello world";
46+
// Will output -> echo "hello world";
47+
console.log(unparse(ast, options));
3648
```
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+
3761
## Demo
3862

3963
[See it working](https://chris-l.github.io/php-unparser/)

0 commit comments

Comments
 (0)