Skip to content

Commit 96f0e06

Browse files
committed
misc static
1 parent 4fef3a0 commit 96f0e06

File tree

6 files changed

+39
-10
lines changed

6 files changed

+39
-10
lines changed

.github/workflows/code_analysis.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ jobs:
1717
name: 'Bare Run'
1818
run: bin/console
1919

20+
-
21+
name: 'ECS'
22+
run: composer check-cs
23+
24+
-
25+
name: 'PHPStan'
26+
run: composer phpstan
27+
2028
name: ${{ matrix.actions.name }}
2129
runs-on: ubuntu-latest
2230

composer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
"symplify/smart-file-system": "^9.1",
1111
"symplify/package-builder": "^9.1",
1212
"symplify/console-package-builder": "^9.1",
13-
"nikic/php-parser": "^4.10"
13+
"nikic/php-parser": "^4.10.4"
14+
},
15+
"require-dev": {
16+
"symplify/easy-coding-standard": "^9.1",
17+
"phpstan/phpstan": "^0.12.73",
18+
"phpunit/phpunit": "^9.5",
19+
"symplify/phpstan-extensions": "^9.1"
1420
},
1521
"autoload": {
1622
"psr-4": {
@@ -22,13 +28,9 @@
2228
"Rector\\PhpParserNodesDocs\\Tests\\": "tests"
2329
}
2430
},
25-
"require-dev": {
26-
"symplify/easy-coding-standard": "^9.1",
27-
"phpstan/phpstan": "^0.12.73"
28-
},
2931
"scripts": {
3032
"check-cs": "vendor/bin/ecs check --ansi",
3133
"fix-cs": "vendor/bin/ecs check --fix --ansi",
32-
"phpstan": "vendor/bin/phpstan analyse --ansi"
34+
"phpstan": "vendor/bin/phpstan analyse --ansi --error-format symplify"
3335
}
3436
}

phpstan.neon

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
includes:
2+
# allows symplify error formatter
3+
- vendor/symplify/phpstan-extensions/config/config.neon
4+
5+
parameters:
6+
level: max
7+
8+
paths:
9+
- src
10+
- tests
11+
12+
ignoreErrors:
13+
-
14+
message: '#Cannot cast array<string\>\|bool\|string\|null to string#'
15+
path: src/Command/DumpNodesCommand.php
16+
17+
- '#Method Rector\\PhpParserNodesDocs\\NodeCodeSampleProvider\:\:provide\(\) should return array<class\-string<PhpParser\\Node\>, array<int, Rector\\PhpParserNodesDocs\\ValueObject\\NodeCodeSample\>\> but returns array<class\-string, array<int, Rector\\PhpParserNodesDocs\\ValueObject\\NodeCodeSample\>\>#'

src/NodeCodeSampleProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpParser\Node;
88
use PhpParser\PrettyPrinter\Standard;
9+
use Rector\PhpParserNodesDocs\Exception\ShouldNotHappenException;
910
use Rector\PhpParserNodesDocs\ValueObject\NodeCodeSample;
1011
use Symplify\SmartFileSystem\Finder\SmartFinder;
1112
use Symplify\SmartFileSystem\SmartFileInfo;
@@ -29,7 +30,7 @@ public function __construct(SmartFinder $smartFinder, Standard $standard)
2930
}
3031

3132
/**
32-
* @return array<string, NodeCodeSample[]>
33+
* @return array<class-string<Node>, array<int, NodeCodeSample>>
3334
*/
3435
public function provide(): array
3536
{
@@ -43,7 +44,7 @@ public function provide(): array
4344

4445
$nodeClass = get_class($node);
4546

46-
$printedContent = $this->standard->prettyPrint($node);
47+
$printedContent = $this->standard->prettyPrint([$node]);
4748
$nodeCodeSamplesByNodeClass[$nodeClass][] = new NodeCodeSample(
4849
$fileInfo->getContents(),
4950
$printedContent

src/ValueObject/NodeInfo.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ final class NodeInfo
2424
private $nodeCodeSamples = [];
2525

2626
/**
27+
* @param class-string<\PhpParser\Node> $class
2728
* @param NodeCodeSample[] $nodeCodeSamples
2829
*/
2930
public function __construct(string $class, array $nodeCodeSamples = [])

tests/NodeInfosFactoryTest.php

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

55
namespace Rector\PhpParserNodesDocs\Tests;
66

7-
use Rector\Core\HttpKernel\RectorKernel;
7+
use Rector\PhpParserNodesDocs\HttpKernel\PhpParserNodesDocsKernel;
88
use Rector\PhpParserNodesDocs\NodeInfosFactory;
99
use Symplify\PackageBuilder\Testing\AbstractKernelTestCase;
1010

@@ -17,7 +17,7 @@ final class NodeInfosFactoryTest extends AbstractKernelTestCase
1717

1818
protected function setUp(): void
1919
{
20-
$this->bootKernel(RectorKernel::class);
20+
$this->bootKernel(PhpParserNodesDocsKernel::class);
2121

2222
$this->nodeInfosFactory = $this->getService(NodeInfosFactory::class);
2323
}

0 commit comments

Comments
 (0)