Skip to content

Commit 624dc4f

Browse files
authored
Update README.md
1 parent 335bedc commit 624dc4f

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

README.md

+48-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,53 @@ It does not change AST but collects resolved names into `map[node.Node]string`
6464
- For `Class`, `Interface`, `Trait`, `Function`, `ConstList` nodes collects name with current namespace.
6565
- For `Name`, `Relative`, `FullyQualified` nodes resolves `use` aliases and collects a fully qualified name.
6666

67+
## Pretty printer
68+
69+
```Golang
70+
nodes := &stmt.StmtList{
71+
Stmts: []node.Node{
72+
&stmt.Namespace{
73+
NamespaceName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
74+
},
75+
&stmt.Class{
76+
Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
77+
ClassName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}},
78+
Extends: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}},
79+
Stmts: []node.Node{
80+
&stmt.ClassMethod{
81+
Modifiers: []node.Node{&node.Identifier{Value: "public"}},
82+
MethodName: &node.Identifier{Value: "greet"},
83+
Stmts: []node.Node{
84+
&stmt.Echo{
85+
Exprs: []node.Node{
86+
&scalar.String{Value: "'Hello world'"},
87+
},
88+
},
89+
},
90+
},
91+
},
92+
},
93+
},
94+
}
95+
96+
file := os.Stdout
97+
p := printer.NewPrinter(file, " ")
98+
p.PrintFile(nodes)
99+
```
100+
101+
Output:
102+
```PHP
103+
<?php
104+
namespace Foo;
105+
abstract class Bar extends Baz
106+
{
107+
public function greet()
108+
{
109+
echo 'Hello world';
110+
}
111+
}
112+
```
113+
67114
## Roadmap
68115
- [X] Lexer
69116
- [x] PHP 7 syntax analyzer
@@ -75,9 +122,9 @@ It does not change AST but collects resolved names into `map[node.Node]string`
75122
- [x] PHP 5 syntax analyzer
76123
- [x] Tests
77124
- [x] Namespace resolver
125+
- [x] Pretty printer
78126
- [ ] PhpDocComment parser
79127
- [ ] Error handling
80128
- [ ] Stabilize api
81129
- [ ] Documentation
82-
- [ ] Pretty printer
83130
- [ ] Code flow graph

0 commit comments

Comments
 (0)