mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-16 21:08:19 +01:00
add dump_node() helper functoin (#6229)
This commit is contained in:
parent
ba2d96c583
commit
3f3811ab21
@ -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": {
|
||||
|
@ -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);
|
||||
|
32
src/functions/node_helper.php
Normal file
32
src/functions/node_helper.php
Normal 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);
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ use PhpParser\Node;
|
||||
use PhpParser\PrettyPrinter\Standard;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
/**
|
||||
* @param Node|Node[] $node
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user