From e4505de3462a9bc0d89f895a88724ae2c5b81401 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sat, 27 Jan 2018 18:40:22 +0100 Subject: [PATCH] Move FAQ into component documentation --- README.md | 3 ++- doc/README.md | 3 ++- doc/{5_FAQ.markdown => component/FAQ.markdown} | 0 doc/component/Pretty_printing.markdown | 10 +++++++--- 4 files changed, 11 insertions(+), 5 deletions(-) rename doc/{5_FAQ.markdown => component/FAQ.markdown} (100%) diff --git a/README.md b/README.md index 4c00619..d90acda 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/doc/README.md b/doc/README.md index c055f8b..e32cac8 100644 --- a/doc/README.md +++ b/doc/README.md @@ -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 diff --git a/doc/5_FAQ.markdown b/doc/component/FAQ.markdown similarity index 100% rename from doc/5_FAQ.markdown rename to doc/component/FAQ.markdown diff --git a/doc/component/Pretty_printing.markdown b/doc/component/Pretty_printing.markdown index 186c278..40c35e6 100644 --- a/doc/component/Pretty_printing.markdown +++ b/doc/component/Pretty_printing.markdown @@ -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