add dump_node() helper functoin (#6229)

This commit is contained in:
Tomas Votruba 2021-04-24 16:22:36 +02:00 committed by GitHub
parent ba2d96c583
commit 3f3811ab21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 6 deletions

View File

@ -63,7 +63,8 @@
"symplify/skipper": "^9.2.19",
"symplify/smart-file-system": "^9.2.19",
"symplify/symfony-php-config": "^9.2.19",
"webmozart/assert": "^1.10"
"webmozart/assert": "^1.10",
"tracy/tracy": "^2.8"
},
"require-dev": {
"symplify/rule-doc-generator": "^9.2.19",
@ -79,8 +80,7 @@
"symplify/easy-coding-standard": "^9.2.19",
"symplify/easy-testing": "^9.2.19",
"symplify/phpstan-extensions": "^9.2.19",
"symplify/phpstan-rules": "^9.2",
"tracy/tracy": "^2.8"
"symplify/phpstan-rules": "^9.2"
},
"replace": {
"rector/rector-prefixed": "self.version"
@ -90,7 +90,10 @@
"Rector\\": ["packages", "rules"],
"Rector\\Core\\": "src",
"Rector\\Compiler\\": "utils/compiler/src"
}
},
"files": [
"src/functions/node_helper.php"
]
},
"autoload-dev": {
"psr-4": {
@ -118,8 +121,7 @@
"rules-tests/Restoration/Rector/Use_/RestoreFullyQualifiedNameRector/Source/ShortClassOnly.php",
"rules-tests/Transform/Rector/FuncCall/FuncCallToMethodCallRector/Source/some_view_function.php",
"rules-tests/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector/Source/MyBar.php",
"rules-tests/TypeDeclaration/Rector/Property/CompleteVarDocTypePropertyRector/Source/EventDispatcher.php",
"tests/debug_functions.php"
"rules-tests/TypeDeclaration/Rector/Property/CompleteVarDocTypePropertyRector/Source/EventDispatcher.php"
]
},
"scripts": {

View File

@ -66,6 +66,7 @@ return static function (ContainerConfigurator $containerConfigurator): void {
__DIR__ . '/../src/ValueObject',
__DIR__ . '/../src/Bootstrap',
__DIR__ . '/../src/PhpParser/Node/CustomNode',
__DIR__ . '/../src/functions',
]);
$services->alias(SymfonyApplication::class, ConsoleApplication::class);

View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
use PhpParser\Node;
use PhpParser\PrettyPrinter\Standard;
use Tracy\Dumper;
function dump_node(Node $node, int $depth = 2): void
{
Dumper::dump($node, [
Dumper::DEPTH => $depth,
]);
}
/**
* @param Node|Node[] $node
*/
function print_node($node): void
{
$standard = new Standard();
if (is_array($node)) {
foreach ($node as $singleNode) {
$printedContent = $standard->prettyPrint([$singleNode]);
Dumper::dump($printedContent);
}
} else {
$printedContent = $standard->prettyPrint([$node]);
Dumper::dump($printedContent);
}
}

View File

@ -6,6 +6,7 @@ use PhpParser\Node;
use PhpParser\PrettyPrinter\Standard;
require __DIR__ . '/../vendor/autoload.php';
/**
* @param Node|Node[] $node
*/