mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +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)
|
2. [Usage of basic components](doc/2_Usage_of_basic_components.markdown)
|
||||||
3. [Other node tree representations](doc/3_Other_node_tree_representations.markdown)
|
3. [Other node tree representations](doc/3_Other_node_tree_representations.markdown)
|
||||||
4. [Code generation](doc/4_Code_generation.markdown)
|
4. [Code generation](doc/4_Code_generation.markdown)
|
||||||
5. [Frequently asked questions](doc/5_FAQ.markdown)
|
|
||||||
|
|
||||||
Component documentation:
|
Component documentation:
|
||||||
|
|
||||||
@ -210,6 +209,8 @@ Component documentation:
|
|||||||
* Disabling XDebug
|
* Disabling XDebug
|
||||||
* Reusing objects
|
* Reusing objects
|
||||||
* Garbage collection impact
|
* 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_3_x]: https://github.com/nikic/PHP-Parser/tree/3.x/doc
|
||||||
[doc_master]: https://github.com/nikic/PHP-Parser/tree/master/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)
|
2. [Usage of basic components](2_Usage_of_basic_components.markdown)
|
||||||
3. [Other node tree representations](3_Other_node_tree_representations.markdown)
|
3. [Other node tree representations](3_Other_node_tree_representations.markdown)
|
||||||
4. [Code generation](4_Code_generation.markdown)
|
4. [Code generation](4_Code_generation.markdown)
|
||||||
5. [Frequently asked questions](5_FAQ.markdown)
|
|
||||||
|
|
||||||
Component documentation
|
Component documentation
|
||||||
-----------------------
|
-----------------------
|
||||||
@ -34,3 +33,5 @@ Component documentation
|
|||||||
* Disabling XDebug
|
* Disabling XDebug
|
||||||
* Reusing objects
|
* Reusing objects
|
||||||
* Garbage collection impact
|
* 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
|
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
|
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
|
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
|
attempts to preserve the formatting of code, those AST nodes have not changed, and only reformat
|
||||||
code which has been modified or newly inserted.
|
code which has been modified or newly inserted.
|
||||||
|
|
||||||
Use of the formatting-preservation functionality currently requires some additional preparatory
|
Use of the formatting-preservation functionality requires some additional preparatory steps:
|
||||||
steps:
|
|
||||||
|
|
||||||
```php
|
```php
|
||||||
use PhpParser\{Lexer, NodeTraverser, NodeVisitor, Parser, PrettyPrinter};
|
use PhpParser\{Lexer, NodeTraverser, NodeVisitor, Parser, PrettyPrinter};
|
||||||
@ -86,6 +85,11 @@ $newStmts = $traverser->traverse($oldStmts);
|
|||||||
$newCode = $printer->printFormatPreserving($newStmts, $oldStmts, $oldTokens);
|
$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
|
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
|
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
|
[issue #344](https://github.com/nikic/PHP-Parser/issues/344). If you encounter problems while using
|
||||||
|
Loading…
Reference in New Issue
Block a user