Skip to content

Commit 799418c

Browse files
committed
enable commands
1 parent 804644f commit 799418c

File tree

8 files changed

+49
-17
lines changed

8 files changed

+49
-17
lines changed

.github/workflow/code_analysis.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@ jobs:
1111
actions:
1212
-
1313
name: 'Validate'
14-
# this is very slow, so it has to be in own workflow
1514
run: composer validate --strict
1615

16+
-
17+
name: 'Bare Run'
18+
run: bin/console
19+
1720
name: ${{ matrix.actions.name }}
1821
runs-on: ubuntu-latest
1922

2023
steps:
2124
- uses: actions/checkout@v2
2225

23-
# see https://github.com/shivammathur/setup-php
2426
-
2527
uses: shivammathur/setup-php@v2
2628
with:
27-
php-version: 7.3
29+
php-version: 8.0
2830
coverage: none
2931

3032
- uses: "ramsey/composer-install@v1"
3133

32-
- run: ${{ matrix.actions.run }}
34+
- run: ${{ matrix.actions.run }}

bin/console.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
declare(strict_types=1);
66

7-
use Symfony\Component\Console\Input\ArgvInput;
7+
use Rector\PhpParserNodesDocs\HttpKernel\PhpParserNodesDocsKernel;
88
use Symplify\SymplifyKernel\ValueObject\KernelBootAndApplicationRun;
99

1010
require_once __DIR__ . '/../vendor/autoload.php';
1111

12-
$kernelBootAndApplicationRun = new KernelBootAndApplicationRun(MonorepoBuilderKernel::class);
13-
$kernelBootAndApplicationRun->run();
12+
$kernelBootAndApplicationRun = new KernelBootAndApplicationRun(PhpParserNodesDocsKernel::class);
13+
$kernelBootAndApplicationRun->run();

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"symfony/dependency-injection": "^5.2",
99
"symplify/symplify-kernel": "^9.1",
1010
"symplify/smart-file-system": "^9.1",
11-
"symplify/package-builder": "^9.1"
11+
"symplify/package-builder": "^9.1",
12+
"symplify/console-package-builder": "^9.1",
13+
"nikic/php-parser": "^4.10"
1214
},
1315
"autoload": {
1416
"psr-4": {

config/config.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
declare(strict_types=1);
44

5+
use PhpParser\PrettyPrinter\Standard;
56
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
67
use Symplify\SmartFileSystem\Finder\SmartFinder;
78

@@ -14,7 +15,8 @@
1415
->autoconfigure();
1516

1617
$services->load('Rector\PhpParserNodesDocs\\', __DIR__ . '/../src')
17-
->exclude([__DIR__ . '/../src/ValueObject']);
18+
->exclude([__DIR__ . '/../src/ValueObject', __DIR__ . '/../src/HttpKernel']);
1819

1920
$services->set(SmartFinder::class);
21+
$services->set(Standard::class);
2022
};

src/Command/DumpNodesCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(
5858

5959
protected function configure(): void
6060
{
61-
$this->setDescription('[DOCS] Dump overview of all Nodes');
61+
$this->setDescription('Dump nodes overview');
6262

6363
$this->addOption(
6464
self::OUTPUT_FILE,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\PhpParserNodesDocs\Exception;
6+
7+
use Exception;
8+
9+
final class ShouldNotHappenException extends Exception
10+
{
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Rector\PhpParserNodesDocs\HttpKernel;
6+
7+
use Symfony\Component\Config\Loader\LoaderInterface;
8+
use Symplify\SymplifyKernel\HttpKernel\AbstractSymplifyKernel;
9+
10+
final class PhpParserNodesDocsKernel extends AbstractSymplifyKernel
11+
{
12+
public function registerContainerConfiguration(LoaderInterface $loader): void
13+
{
14+
$loader->load(__DIR__ . '/../../config/config.php');
15+
}
16+
}

src/NodeCodeSampleProvider.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
namespace Rector\PhpParserNodesDocs;
66

77
use PhpParser\Node;
8-
use Rector\Core\Exception\ShouldNotHappenException;
9-
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
8+
use PhpParser\PrettyPrinter\Standard;
109
use Rector\PhpParserNodesDocs\ValueObject\NodeCodeSample;
1110
use Symplify\SmartFileSystem\Finder\SmartFinder;
1211
use Symplify\SmartFileSystem\SmartFileInfo;
@@ -19,14 +18,14 @@ final class NodeCodeSampleProvider
1918
private $smartFinder;
2019

2120
/**
22-
* @var BetterStandardPrinter
21+
* @var Standard
2322
*/
24-
private $betterStandardPrinter;
23+
private $standard;
2524

26-
public function __construct(SmartFinder $smartFinder, BetterStandardPrinter $betterStandardPrinter)
25+
public function __construct(SmartFinder $smartFinder, Standard $standard)
2726
{
2827
$this->smartFinder = $smartFinder;
29-
$this->betterStandardPrinter = $betterStandardPrinter;
28+
$this->standard = $standard;
3029
}
3130

3231
/**
@@ -44,7 +43,7 @@ public function provide(): array
4443

4544
$nodeClass = get_class($node);
4645

47-
$printedContent = $this->betterStandardPrinter->print($node);
46+
$printedContent = $this->standard->prettyPrint($node);
4847
$nodeCodeSamplesByNodeClass[$nodeClass][] = new NodeCodeSample(
4948
$fileInfo->getContents(),
5049
$printedContent

0 commit comments

Comments
 (0)