mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-03 09:50:49 +00:00
make node_helper.php safe for similar names
This commit is contained in:
parent
c98f12d847
commit
dedd4b55fe
|
@ -6,33 +6,44 @@ use PhpParser\Node;
|
||||||
use PhpParser\PrettyPrinter\Standard;
|
use PhpParser\PrettyPrinter\Standard;
|
||||||
use Tracy\Dumper;
|
use Tracy\Dumper;
|
||||||
|
|
||||||
function dn(Node $node, int $depth = 2): void
|
if (! function_exists('dn')) {
|
||||||
{
|
function dn(Node $node, int $depth = 2): void
|
||||||
dump_node($node, $depth);
|
{
|
||||||
}
|
dump_node($node, $depth);
|
||||||
|
}
|
||||||
|
}
|
||||||
function dump_node(Node $node, int $depth = 2): void
|
|
||||||
{
|
|
||||||
Dumper::dump($node, [
|
if (! function_exists('dump_node')) {
|
||||||
Dumper::DEPTH => $depth,
|
/**
|
||||||
]);
|
* @param Node|Node[] $node
|
||||||
}
|
*/
|
||||||
|
function dump_node($node, int $depth = 2): void
|
||||||
/**
|
{
|
||||||
* @param Node|Node[] $node
|
$nodes = is_array($node) ? $node : [$node];
|
||||||
*/
|
|
||||||
function print_node($node): void
|
foreach ($nodes as $node) {
|
||||||
{
|
Dumper::dump($node, [
|
||||||
$standard = new Standard();
|
Dumper::DEPTH => $depth,
|
||||||
|
]);
|
||||||
if (is_array($node)) {
|
}
|
||||||
foreach ($node as $singleNode) {
|
}
|
||||||
$printedContent = $standard->prettyPrint([$singleNode]);
|
}
|
||||||
Dumper::dump($printedContent);
|
|
||||||
}
|
|
||||||
} else {
|
if (! function_exists('print_node')) {
|
||||||
$printedContent = $standard->prettyPrint([$node]);
|
/**
|
||||||
Dumper::dump($printedContent);
|
* @param Node|Node[] $node
|
||||||
|
*/
|
||||||
|
function print_node($node): void
|
||||||
|
{
|
||||||
|
$standard = new Standard();
|
||||||
|
|
||||||
|
$nodes = is_array($node) ? $node : [$node];
|
||||||
|
|
||||||
|
foreach ($nodes as $node) {
|
||||||
|
$printedContent = $standard->prettyPrint([$node]);
|
||||||
|
Dumper::dump($printedContent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user