Skip to content

Commit

Permalink
naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Mar 6, 2024
1 parent dfe68b7 commit 8120d53
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,4 @@ parameters:
# false positive
-
message: '#Parameters should use "array" types as the only types passed to this method#'
path: src/Util/PrintNodes.php
path: src/Util/NodePrinter.php
6 changes: 3 additions & 3 deletions src/Console/Command/DetectNodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Rector\Console\Command;

use Rector\PhpParser\Parser\SimplePhpParser;
use Rector\Util\PrintNodes;
use Rector\Util\NodePrinter;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -18,7 +18,7 @@ final class DetectNodeCommand extends Command
{
public function __construct(
private readonly SimplePhpParser $simplePhpParser,
private readonly PrintNodes $printNodes,
private readonly NodePrinter $nodePrinter,
private readonly SymfonyStyle $symfonyStyle
) {
parent::__construct();
Expand Down Expand Up @@ -61,6 +61,6 @@ private function askQuestionAndDumpNode(): void
return;
}

$this->printNodes->outputNodes($nodes);
$this->nodePrinter->printNodes($nodes);
}
}
10 changes: 5 additions & 5 deletions src/Util/PrintNodes.php → src/Util/NodePrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Rector\CustomRules\SimpleNodeDumper;
use Symfony\Component\Console\Style\SymfonyStyle;

class PrintNodes
final readonly class NodePrinter
{
/**
* @var string
Expand All @@ -23,14 +23,15 @@ class PrintNodes
*/
private const PROPERTY_KEY_REGEX = '#(?<key>[\w\d]+)\:#';

public function __construct(private readonly SymfonyStyle $symfonyStyle)
{
public function __construct(
private SymfonyStyle $symfonyStyle
) {
}

/**
* @param Node|Node[] $nodes
*/
public function outputNodes(Node|array $nodes): void
public function printNodes(Node|array $nodes): void
{
$dumpedNodesContents = SimpleNodeDumper::dump($nodes);

Expand All @@ -41,7 +42,6 @@ public function outputNodes(Node|array $nodes): void
$this->symfonyStyle->newLine();
}


private function addConsoleColors(string $contents): string
{
// decorate class names
Expand Down
16 changes: 8 additions & 8 deletions src/functions/node_helper.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

declare(strict_types=1);
use Illuminate\Container\Container;
use Rector\Console\Style\SymfonyStyleFactory;
use Rector\Util\PrintNodes;

use Illuminate\Container\Container;
use PhpParser\Node;
use PhpParser\PrettyPrinter\Standard;
use Rector\Console\Style\SymfonyStyleFactory;
use Rector\Util\NodePrinter;
use Symfony\Component\Console\Output\OutputInterface;

if (! function_exists('print_node')) {
Expand All @@ -32,16 +32,16 @@ function print_node(Node | array $node): void
*/
function dump_node(Node|array $node): void
{
$styler = Container::getInstance()
$symfonyStyle = Container::getInstance()
->make(SymfonyStyleFactory::class)
->create();

// we turn up the verbosity so it's visible in tests overriding the
// default which is to be quite during tests
$styler->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);

$styler->newLine();
$symfonyStyle->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
$symfonyStyle->newLine();

(new PrintNodes($styler))->outputNodes($node);
$nodePrinter = new NodePrinter($symfonyStyle);
$nodePrinter->printNodes($node);
}
}

0 comments on commit 8120d53

Please sign in to comment.