mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 08:50:50 +00:00
README: add dump_node() function note
This commit is contained in:
parent
514a8b0513
commit
2fa60fc071
22
README.md
22
README.md
|
@ -196,18 +196,20 @@ Or with Xdebug:
|
|||
vendor/bin/rector process src/Controller --dry-run --xdebug
|
||||
```
|
||||
|
||||
To assist with echo-style debugging rector provides a [`print_node()` helper](tests/debug_functions.php) method
|
||||
which is useful to pretty-print AST-nodes:
|
||||
To assist with simple debugging Rector provides a 2 helps to pretty-print AST-nodes:
|
||||
|
||||
```php
|
||||
/**
|
||||
* @param Class_ $node
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
print_node($node);
|
||||
die;
|
||||
}
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
|
||||
$node = new String_('hello world!');
|
||||
|
||||
// prints node to string, as PHP code displays it
|
||||
print_node($node);
|
||||
|
||||
// dump nested node object with nested properties
|
||||
dump_node($node);
|
||||
// 2nd argument is how deep the nesting is - this makes sure the dump is short and useful
|
||||
dump_node($node, 1);
|
||||
```
|
||||
|
||||
<br>
|
||||
|
|
Loading…
Reference in New Issue
Block a user