mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-26 20:04:48 +01:00
Move FAQ into component documentation
This commit is contained in:
parent
a513ccabb7
commit
e4505de346
@ -185,7 +185,6 @@ Documentation
|
||||
2. [Usage of basic components](doc/2_Usage_of_basic_components.markdown)
|
||||
3. [Other node tree representations](doc/3_Other_node_tree_representations.markdown)
|
||||
4. [Code generation](doc/4_Code_generation.markdown)
|
||||
5. [Frequently asked questions](doc/5_FAQ.markdown)
|
||||
|
||||
Component documentation:
|
||||
|
||||
@ -210,6 +209,8 @@ Component documentation:
|
||||
* Disabling XDebug
|
||||
* Reusing objects
|
||||
* Garbage collection impact
|
||||
* [Frequently asked questions](component/FAQ.markdown)
|
||||
* Parent and sibling references
|
||||
|
||||
[doc_3_x]: https://github.com/nikic/PHP-Parser/tree/3.x/doc
|
||||
[doc_master]: https://github.com/nikic/PHP-Parser/tree/master/doc
|
||||
|
@ -8,7 +8,6 @@ Guide
|
||||
2. [Usage of basic components](2_Usage_of_basic_components.markdown)
|
||||
3. [Other node tree representations](3_Other_node_tree_representations.markdown)
|
||||
4. [Code generation](4_Code_generation.markdown)
|
||||
5. [Frequently asked questions](5_FAQ.markdown)
|
||||
|
||||
Component documentation
|
||||
-----------------------
|
||||
@ -34,3 +33,5 @@ Component documentation
|
||||
* Disabling XDebug
|
||||
* Reusing objects
|
||||
* Garbage collection impact
|
||||
* [Frequently asked questions](component/FAQ.markdown)
|
||||
* Parent and sibling references
|
||||
|
@ -50,14 +50,13 @@ Formatting-preserving pretty printing
|
||||
|
||||
For automated code refactoring, migration and similar, you will usually only want to modify a small
|
||||
portion of the code and leave the remainder alone. The basic pretty printer is not suitable for
|
||||
this, because it will also reformat parts of the code, which have not been modified.
|
||||
this, because it will also reformat parts of the code which have not been modified.
|
||||
|
||||
Since PHP-Parser 4.0 an experimental formatting-preserving pretty-printing mode is available, which
|
||||
attempts to preserve the formatting of code, those AST nodes have not changed, and only reformat
|
||||
code which has been modified or newly inserted.
|
||||
|
||||
Use of the formatting-preservation functionality currently requires some additional preparatory
|
||||
steps:
|
||||
Use of the formatting-preservation functionality requires some additional preparatory steps:
|
||||
|
||||
```php
|
||||
use PhpParser\{Lexer, NodeTraverser, NodeVisitor, Parser, PrettyPrinter};
|
||||
@ -86,6 +85,11 @@ $newStmts = $traverser->traverse($oldStmts);
|
||||
$newCode = $printer->printFormatPreserving($newStmts, $oldStmts, $oldTokens);
|
||||
```
|
||||
|
||||
If you make use of the name resolution functionality, you will likely want to disable the
|
||||
`replaceNames` option. This will add resolved names as attributes, instead of directlying modifying
|
||||
the AST and causing spurious changes to the pretty printed code. For more information, see the
|
||||
[name resolution documentation](Name_resolution.markdown).
|
||||
|
||||
This functionality is experimental and not yet fully implemented. It should not provide incorrect
|
||||
code, but it may sometimes reformat more code than necessary. Open issues are tracked in
|
||||
[issue #344](https://github.com/nikic/PHP-Parser/issues/344). If you encounter problems while using
|
||||
|
Loading…
Reference in New Issue
Block a user