diff --git a/.github/workflows/code_analysis.yaml b/.github/workflows/code_analysis.yaml
index 167ad19..10d6763 100644
--- a/.github/workflows/code_analysis.yaml
+++ b/.github/workflows/code_analysis.yaml
@@ -15,15 +15,15 @@ jobs:
-
name: 'Bare Run'
- run: bin/console
+ run: php bin/dump-nodes.php
-
name: 'ECS'
- run: composer check-cs
+ run: vendor/bin/ecs
-
name: 'PHPStan'
- run: composer phpstan
+ run: vendor/bin/phpstan
name: ${{ matrix.actions.name }}
runs-on: ubuntu-latest
@@ -34,7 +34,7 @@ jobs:
-
uses: shivammathur/setup-php@v2
with:
- php-version: 8.1
+ php-version: 8.3
coverage: none
- uses: "ramsey/composer-install@v1"
diff --git a/README.md b/README.md
index 48add1a..530c779 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
-# Node Overview
+# Node Overview for PHP-Parser 5.6 (2025)
Here you can find overview of commonly used nodes and how to build PHP code from them. For all nodes, [check php-parser code](https://github.com/nikic/PHP-Parser/tree/master/lib/PhpParser/Node).
-## `PhpParser\Node\Const_`
+## `PhpParser\Node\ArrayItem`
### Example PHP Code
@@ -11,29 +11,34 @@ Here you can find overview of commonly used nodes and how to build PHP code from
declare(strict_types=1);
-use PhpParser\Node\Const_;
+use PhpParser\Node\Expr\ArrayItem;
+use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\String_;
-return new Const_('CONSTANT_NAME', new String_('default'));
+$value = new Variable('Tom');
+$key = new String_('name');
+
+return new ArrayItem($value, $key);
```
↓
```php
-CONSTANT_NAME = 'default'
+'name' => $Tom
```
### Public Properties
- * `$name` - `/** @var Identifier Name */`
+ * `$key` - `/** @var null|Expr Key */`
* `$value` - `/** @var Expr Value */`
- * `$namespacedName` - `/** @var Name|null Namespaced name (if using NameResolver) */`
+ * `$byRef` - `/** @var bool Whether to assign by reference */`
+ * `$unpack` - `/** @var bool Whether to unpack the argument */`
-## `PhpParser\Node\Expr\ArrayDimFetch`
+## `PhpParser\Node\ClosureUse`
### Example PHP Code
@@ -42,32 +47,30 @@ CONSTANT_NAME = 'default'
declare(strict_types=1);
-use PhpParser\Node\Expr\ArrayDimFetch;
+use PhpParser\Node\Expr\ClosureUse;
use PhpParser\Node\Expr\Variable;
-use PhpParser\Node\Scalar\LNumber;
$variable = new Variable('variableName');
-$dimension = new LNumber(0);
-return new ArrayDimFetch($variable, $dimension);
+return new ClosureUse($variable);
```
↓
```php
-$variableName[0]
+$variableName
```
### Public Properties
- * `$var` - `/** @var Expr Variable */`
- * `$dim` - `/** @var null|Expr Array index / dim */`
+ * `$var` - `/** @var Expr\Variable Variable to use */`
+ * `$byRef` - `/** @var bool Whether to use by reference */`
-## `PhpParser\Node\Expr\ArrayItem`
+## `PhpParser\Node\Const_`
### Example PHP Code
@@ -76,30 +79,59 @@ $variableName[0]
declare(strict_types=1);
-use PhpParser\Node\Expr\ArrayItem;
-use PhpParser\Node\Expr\Variable;
+use PhpParser\Node\Const_;
use PhpParser\Node\Scalar\String_;
-$value = new Variable('Tom');
-$key = new String_('name');
-
-return new ArrayItem($value, $key);
+return new Const_('CONSTANT_NAME', new String_('default'));
```
↓
```php
-'name' => $Tom
+CONSTANT_NAME = 'default'
```
### Public Properties
- * `$key` - `/** @var null|Expr Key */`
+ * `$name` - `/** @var Identifier Name */`
* `$value` - `/** @var Expr Value */`
- * `$byRef` - `/** @var bool Whether to assign by reference */`
- * `$unpack` - `/** @var bool Whether to unpack the argument */`
+ * `$namespacedName` - `/** @var Name|null Namespaced name (if using NameResolver) */`
+
+
+
+## `PhpParser\Node\Expr\ArrayDimFetch`
+
+### Example PHP Code
+
+```php
+
+
+### Public Properties
+
+ * `$var` - `/** @var Expr Variable */`
+ * `$dim` - `/** @var null|Expr Array index / dim */`
@@ -128,14 +160,14 @@ return new Array_([$arrayItem]);
↓
```php
-array('name' => $Tom)
+['name' => $Tom]
```
### Public Properties
- * `$items` - `/** @var (ArrayItem|null)[] Items */`
+ * `$items` - `/** @var ArrayItem[] Items */`
@@ -166,11 +198,11 @@ fn() => 1
### Public Properties
- * `$static` - `/** @var bool */`
- * `$byRef` - `/** @var bool */`
+ * `$static` - `/** @var bool Whether the closure is static */`
+ * `$byRef` - `/** @var bool Whether to return by reference */`
* `$params` - `/** @var Node\Param[] */`
* `$returnType` - `/** @var null|Node\Identifier|Node\Name|Node\ComplexType */`
- * `$expr` - `/** @var Expr */`
+ * `$expr` - `/** @var Expr Expression body */`
* `$attrGroups` - `/** @var Node\AttributeGroup[] */`
@@ -779,39 +811,7 @@ return new ClassConstFetch($class, 'SOME_CONSTANT');
### Public Properties
* `$class` - `/** @var Name|Expr Class name */`
- * `$name` - `/** @var Identifier|Error Constant name */`
-
-
-
-## `PhpParser\Node\Expr\ClosureUse`
-
-### Example PHP Code
-
-```php
-
-
-### Public Properties
-
- * `$var` - `/** @var Expr\Variable Variable to use */`
- * `$byRef` - `/** @var bool Whether to use by reference */`
+ * `$name` - `/** @var Identifier|Expr|Error Constant name */`
@@ -1084,7 +1084,7 @@ return new List_($arrayItems);
↓
```php
-list($variableName, $anotherVariableName)
+[$variableName, $anotherVariableName]
```
@@ -1131,7 +1131,7 @@ match ($variableName) {
### Public Properties
- * `$cond` - `/** @var Node\Expr */`
+ * `$cond` - `/** @var Node\Expr Condition */`
* `$arms` - `/** @var MatchArm[] */`
@@ -1531,6 +1531,27 @@ throw 'some string'
+```php
+
+
### Public Properties
* `$expr` - `/** @var Node\Expr Expression */`
@@ -1594,8 +1615,8 @@ return new MatchArm($conds, $body);
### Public Properties
- * `$conds` - `/** @var null|Node\Expr[] */`
- * `$body` - `/** @var Node\Expr */`
+ * `$conds` - `/** @var null|list */`
+ * `$body` - ``
@@ -1623,11 +1644,11 @@ shortName
### Public Properties
- * `$parts` - `/**
- * @var string[] Parts of the name
- * @deprecated Use getParts() instead
+ * `$name` - `/**
+ * @psalm-var non-empty-string
+ * @var string Name as string
*/`
- * `$specialClassNames` - ``
+ * `$specialClassNames` - `/** @var array */`
@@ -1655,9 +1676,9 @@ return new FullyQualified('SomeNamespace\ShortName');
### Public Properties
- * `$parts` - `/**
- * @var string[] Parts of the name
- * @deprecated Use getParts() instead
+ * `$name` - `/**
+ * @psalm-var non-empty-string
+ * @var string Name as string
*/`
@@ -1671,9 +1692,10 @@ return new FullyQualified('SomeNamespace\ShortName');
declare(strict_types=1);
+use PhpParser\Node\Name;
use PhpParser\Node\NullableType;
-return new NullableType('SomeType');
+return new NullableType(new Name('SomeType'));
```
↓
@@ -1722,12 +1744,13 @@ $variableName
* `$variadic` - `/** @var bool Whether this is a variadic argument */`
* `$var` - `/** @var Expr\Variable|Expr\Error Parameter variable */`
* `$default` - `/** @var null|Expr Default value */`
- * `$flags` - `/** @var int */`
+ * `$flags` - `/** @var int Optional visibility flags */`
* `$attrGroups` - `/** @var AttributeGroup[] PHP attribute groups */`
+ * `$hooks` - `/** @var PropertyHook[] Property hooks for promoted properties */`
-## `PhpParser\Node\Scalar\DNumber`
+## `PhpParser\Node\PropertyItem`
### Example PHP Code
@@ -1736,26 +1759,36 @@ $variableName
declare(strict_types=1);
-use PhpParser\Node\Scalar\DNumber;
+use PhpParser\Node\Stmt\Class_;
+use PhpParser\Node\Stmt\Property;
+use PhpParser\Node\Stmt\PropertyProperty;
-return new DNumber(10.5);
+$class = new Class_('ClassName');
+
+$propertyProperty = new PropertyProperty('someProperty');
+$property = new Property(Class_::MODIFIER_PRIVATE, [$propertyProperty]);
+
+$class->stmts[] = $property;
+
+return $propertyProperty;
```
↓
```php
-10.5
+$someProperty
```
### Public Properties
- * `$value` - `/** @var float Number value */`
+ * `$name` - `/** @var Node\VarLikeIdentifier Name */`
+ * `$default` - `/** @var null|Node\Expr Default */`
-## `PhpParser\Node\Scalar\Encapsed`
+## `PhpParser\Node\Scalar\Float_`
### Example PHP Code
@@ -1764,27 +1797,26 @@ return new DNumber(10.5);
declare(strict_types=1);
-use PhpParser\Node\Expr\Variable;
-use PhpParser\Node\Scalar\Encapsed;
+use PhpParser\Node\Scalar\DNumber;
-return new Encapsed([new Variable('variableName')]);
+return new DNumber(10.5);
```
↓
```php
-"{$variableName}"
+10.5
```
### Public Properties
- * `$parts` - `/** @var Expr[] list of string parts */`
+ * `$value` - `/** @var float Number value */`
-## `PhpParser\Node\Scalar\LNumber`
+## `PhpParser\Node\Scalar\Int_`
### Example PHP Code
@@ -1812,6 +1844,35 @@ return new LNumber(1000);
+## `PhpParser\Node\Scalar\InterpolatedString`
+
+### Example PHP Code
+
+```php
+
+
+### Public Properties
+
+ * `$parts` - `/** @var (Expr|InterpolatedStringPart)[] list of string parts */`
+
+
+
## `PhpParser\Node\Scalar\String_`
### Example PHP Code
@@ -1837,7 +1898,39 @@ return new String_('some string');
### Public Properties
* `$value` - `/** @var string String value */`
- * `$replacements` - ``
+ * `$replacements` - `/** @var array Escaped character to its decoded value */`
+
+
+
+## `PhpParser\Node\StaticVar`
+
+### Example PHP Code
+
+```php
+
+
+### Public Properties
+
+ * `$var` - `/** @var Expr\Variable Variable */`
+ * `$default` - `/** @var null|Node\Expr Default value */`
@@ -1873,7 +1966,8 @@ public const SOME_CLASS_CONSTANT = 'default value';
* `$flags` - `/** @var int Modifiers */`
* `$consts` - `/** @var Node\Const_[] Constant declarations */`
- * `$attrGroups` - `/** @var Node\AttributeGroup[] */`
+ * `$attrGroups` - `/** @var Node\AttributeGroup[] PHP attribute groups */`
+ * `$type` - `/** @var Node\Identifier|Node\Name|Node\ComplexType|null Type declaration */`
@@ -1929,7 +2023,7 @@ return $classMethod;
↓
```php
-private function methodName($paramName) : string
+private function methodName($paramName): string
{
}
```
@@ -1980,7 +2074,7 @@ public function methodName()
* `$returnType` - `/** @var null|Node\Identifier|Node\Name|Node\ComplexType Return type */`
* `$stmts` - `/** @var Node\Stmt[]|null Statements */`
* `$attrGroups` - `/** @var Node\AttributeGroup[] PHP attribute groups */`
- * `$magicNames` - ``
+ * `$magicNames` - `/** @var array */`
@@ -2059,7 +2153,7 @@ final class ClassName extends \ParentClass
### Public Properties
- * `$flags` - `/** @var int Type */`
+ * `$flags` - `/** @var int Modifiers */`
* `$extends` - `/** @var null|Node\Name Name of extended class */`
* `$implements` - `/** @var Node\Name[] Names of implemented interfaces */`
* `$name` - `/** @var Node\Identifier|null Name */`
@@ -2098,6 +2192,7 @@ const CONSTANT_IN_CLASS = 'default value';
### Public Properties
* `$consts` - `/** @var Node\Const_[] Constant declarations */`
+ * `$attrGroups` - `/** @var Node\AttributeGroup[] PHP attribute groups */`
@@ -2129,7 +2224,7 @@ declare (strict_types=1);
### Public Properties
- * `$declares` - `/** @var DeclareDeclare[] List of declares */`
+ * `$declares` - `/** @var DeclareItem[] List of declares */`
* `$stmts` - `/** @var Node\Stmt[]|null Statements */`
@@ -2446,14 +2541,14 @@ labelName:
declare(strict_types=1);
-use PhpParser\Node\Stmt\Class_;
+use PhpParser\Modifiers;
use PhpParser\Node\Stmt\Property;
use PhpParser\Node\Stmt\PropertyProperty;
use PhpParser\Node\VarLikeIdentifier;
$propertyProperty = new PropertyProperty(new VarLikeIdentifier('propertyName'));
-return new Property(Class_::MODIFIER_PUBLIC, [$propertyProperty], [], 'string');
+return new Property(Modifiers::PUBLIC, [$propertyProperty], [], new \PhpParser\Node\Identifier('string'));
```
↓
@@ -2512,79 +2607,10 @@ public static $firstProperty, $secondProperty;
### Public Properties
* `$flags` - `/** @var int Modifiers */`
- * `$props` - `/** @var PropertyProperty[] Properties */`
+ * `$props` - `/** @var PropertyItem[] Properties */`
* `$type` - `/** @var null|Identifier|Name|ComplexType Type declaration */`
* `$attrGroups` - `/** @var Node\AttributeGroup[] PHP attribute groups */`
-
-
-
-## `PhpParser\Node\Stmt\PropertyProperty`
-
-### Example PHP Code
-
-```php
-stmts[] = $property;
-
-return $propertyProperty;
-```
-
-↓
-
-```php
-$someProperty
-```
-
-
-
-### Public Properties
-
- * `$name` - `/** @var Node\VarLikeIdentifier Name */`
- * `$default` - `/** @var null|Node\Expr Default */`
-
-
-
-## `PhpParser\Node\Stmt\StaticVar`
-
-### Example PHP Code
-
-```php
-
-
-### Public Properties
-
- * `$var` - `/** @var Expr\Variable Variable */`
- * `$default` - `/** @var null|Node\Expr Default value */`
+ * `$hooks` - `/** @var Node\PropertyHook[] Property hooks */`
@@ -2657,37 +2683,6 @@ switch ($variableName) {
-## `PhpParser\Node\Stmt\Throw_`
-
-### Example PHP Code
-
-```php
-
-
-### Public Properties
-
- * `$expr` - `/** @var Node\Expr Expression */`
-
-
-
## `PhpParser\Node\Stmt\TraitUse`
### Example PHP Code
@@ -2893,8 +2888,8 @@ use UsedNamespace;
### Public Properties
- * `$type` - `/** @var int Type of alias */`
- * `$uses` - `/** @var UseUse[] Aliases */`
+ * `$type` - `/** @var self::TYPE_* Type of alias */`
+ * `$uses` - `/** @var UseItem[] Aliases */`
diff --git a/bin/console b/bin/console
deleted file mode 100755
index e7f0299..0000000
--- a/bin/console
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/usr/bin/env php
-create();
-
-/** @var Application $application */
-$application = $container->make(Application::class);
-
-$input = new ArgvInput();
-$output = new ConsoleOutput();
-
-$exitCode = $application->run($input, $output);
-exit($exitCode);
diff --git a/bin/dump-nodes.php b/bin/dump-nodes.php
new file mode 100755
index 0000000..183dcda
--- /dev/null
+++ b/bin/dump-nodes.php
@@ -0,0 +1,28 @@
+create();
+$printedContent = $markdownNodeInfosPrinter->print($nodeInfos);
+
+file_put_contents(getcwd() . '/README.md', $printedContent);
+
+echo sprintf('Documentation for %d nodes was generated to README.md' . PHP_EOL, count($nodeInfos));
+
+// success
+exit(0);
diff --git a/composer.json b/composer.json
index 5bb2dab..30f3991 100644
--- a/composer.json
+++ b/composer.json
@@ -7,17 +7,17 @@
"bin/console.php"
],
"require": {
- "php": "^8.1",
- "symfony/console": "^6.3",
- "nikic/php-parser": "^4.16",
- "illuminate/container": "^10.15",
+ "php": "^8.3",
+ "nikic/php-parser": "^5.6",
"webmozart/assert": "^1.11"
},
"require-dev": {
- "symplify/easy-coding-standard": "^11.5",
- "phpstan/phpstan": "^1.10",
- "phpunit/phpunit": "^10.2",
- "rector/rector": "^0.17.6"
+ "symplify/easy-coding-standard": "^12.6",
+ "phpstan/phpstan": "^2.1",
+ "phpunit/phpunit": "^12.4",
+ "rector/rector": "^2.2.2",
+ "phpstan/phpstan-deprecation-rules": "^2.0",
+ "phpstan/extension-installer": "^1.4"
},
"autoload": {
"psr-4": {
@@ -34,5 +34,10 @@
"fix-cs": "vendor/bin/ecs check --fix --ansi",
"phpstan": "vendor/bin/phpstan analyse --ansi",
"build": "bin/console dump-nodes"
+ },
+ "config": {
+ "allow-plugins": {
+ "phpstan/extension-installer": true
+ }
}
}
diff --git a/ecs.php b/ecs.php
index ce3a451..4629829 100644
--- a/ecs.php
+++ b/ecs.php
@@ -3,17 +3,11 @@
declare(strict_types=1);
use Symplify\EasyCodingStandard\Config\ECSConfig;
-use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
-return static function (ECSConfig $ecsConfig): void {
- $ecsConfig->paths([
+return ECSConfig::configure()
+ ->withPaths([
+ __DIR__ . '/bin',
__DIR__ . '/src',
__DIR__ . '/tests',
- ]);
-
- $ecsConfig->sets([
- SetList::STRICT,
- SetList::COMMON,
- SetList::PSR_12,
- ]);
-};
+ ])
+ ->withPreparedSets(symplify: true, common: true, psr12: true);
diff --git a/phpstan.neon b/phpstan.neon
index 028820a..ce4501d 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,6 +1,14 @@
parameters:
- level: max
+ level: 8
paths:
+ - bin
- src
- tests
+
+ treatPhpDocTypesAsCertain: false
+
+ ignoreErrors:
+ -
+ path: src/Finder/PhpFilesFinder.php
+ identifier: varTag.nativeType
\ No newline at end of file
diff --git a/snippet/nullable_type.php b/snippet/nullable_type.php
index 4adf3a0..d2418f7 100644
--- a/snippet/nullable_type.php
+++ b/snippet/nullable_type.php
@@ -2,6 +2,7 @@
declare(strict_types=1);
+use PhpParser\Node\Name;
use PhpParser\Node\NullableType;
-return new NullableType('SomeType');
+return new NullableType(new Name('SomeType'));
diff --git a/snippet/php_74/property_typed.php b/snippet/php_74/property_typed.php
index 7961ea3..cb8164a 100644
--- a/snippet/php_74/property_typed.php
+++ b/snippet/php_74/property_typed.php
@@ -2,11 +2,11 @@
declare(strict_types=1);
-use PhpParser\Node\Stmt\Class_;
+use PhpParser\Modifiers;
use PhpParser\Node\Stmt\Property;
use PhpParser\Node\Stmt\PropertyProperty;
use PhpParser\Node\VarLikeIdentifier;
$propertyProperty = new PropertyProperty(new VarLikeIdentifier('propertyName'));
-return new Property(Class_::MODIFIER_PUBLIC, [$propertyProperty], [], 'string');
+return new Property(Modifiers::PUBLIC, [$propertyProperty], [], new \PhpParser\Node\Identifier('string'));
diff --git a/snippet/throw_stmt.php b/snippet/throw_stmt.php
index 299fa06..0942c05 100644
--- a/snippet/throw_stmt.php
+++ b/snippet/throw_stmt.php
@@ -2,8 +2,8 @@
declare(strict_types=1);
+use PhpParser\Node\Expr\Throw_;
use PhpParser\Node\Scalar\String_;
-use PhpParser\Node\Stmt\Throw_;
$string = new String_('some string');
diff --git a/src/Command/DumpNodesCommand.php b/src/Command/DumpNodesCommand.php
deleted file mode 100644
index 422c7a7..0000000
--- a/src/Command/DumpNodesCommand.php
+++ /dev/null
@@ -1,44 +0,0 @@
-setName('dump-nodes');
- $this->setDescription('Dump nodes overview');
- }
-
- protected function execute(InputInterface $input, OutputInterface $output): int
- {
- $nodeInfos = $this->nodeInfosFactory->create();
- $printedContent = $this->markdownNodeInfosPrinter->print($nodeInfos);
-
- file_put_contents(getcwd() . '/README.md', $printedContent);
-
- $output->write(PHP_EOL);
-
- $output->writeln(sprintf(
- 'Documentation for %d nodes was generated to README.md' . PHP_EOL,
- count($nodeInfos),
- ));
-
- return self::SUCCESS;
- }
-}
diff --git a/src/DependencyInjection/ContainerFactory.php b/src/DependencyInjection/ContainerFactory.php
deleted file mode 100644
index 6e9412f..0000000
--- a/src/DependencyInjection/ContainerFactory.php
+++ /dev/null
@@ -1,29 +0,0 @@
-singleton(Application::class, function (Container $container) {
- $application = new Application();
-
- /** @var DumpNodesCommand $dumpNodesCommand */
- $dumpNodesCommand = $container->make(DumpNodesCommand::class);
- $application->add($dumpNodesCommand);
-
- return $application;
- });
-
- return $container;
- }
-}
diff --git a/src/Finder/PhpFilesFinder.php b/src/Finder/PhpFilesFinder.php
index 4305cd0..dbf14f7 100644
--- a/src/Finder/PhpFilesFinder.php
+++ b/src/Finder/PhpFilesFinder.php
@@ -42,7 +42,7 @@ public function findPhpFiles(array $paths): array
private function findFilesUsingGlob(string $directory): array
{
// Search for php files in the current directory
- /** @var string[] $phpFiles */
+ /** @var list $phpFiles */
$phpFiles = glob($directory . '/*.php');
// recursively search in subdirectories
diff --git a/src/NodeCodeSampleProvider.php b/src/NodeCodeSampleProvider.php
index c4ab3c9..05b4e26 100644
--- a/src/NodeCodeSampleProvider.php
+++ b/src/NodeCodeSampleProvider.php
@@ -41,10 +41,7 @@ public function provide(): array
$printedContent = $this->standard->prettyPrint([$node]);
- $nodeCodeSamplesByNodeClass[$nodeClass][] = new NodeCodeSample(
- $fileContents,
- $printedContent
- );
+ $nodeCodeSamplesByNodeClass[$nodeClass][] = new NodeCodeSample($fileContents, $printedContent);
}
ksort($nodeCodeSamplesByNodeClass);
diff --git a/src/Printer/MarkdownNodeInfosPrinter.php b/src/Printer/MarkdownNodeInfosPrinter.php
index a49f6c2..245edae 100644
--- a/src/Printer/MarkdownNodeInfosPrinter.php
+++ b/src/Printer/MarkdownNodeInfosPrinter.php
@@ -15,7 +15,7 @@ final class MarkdownNodeInfosPrinter
public function print(array $nodeInfos): string
{
$contentLines = [];
- $contentLines[] = '# Node Overview';
+ $contentLines[] = '# Node Overview for PHP-Parser 5.6 (2025)';
$contentLines[] = 'Here you can find overview of commonly used nodes and how to build PHP code from them. For all nodes, [check php-parser code](https://github.com/nikic/PHP-Parser/tree/master/lib/PhpParser/Node).';
foreach ($nodeInfos as $nodeInfo) {
diff --git a/src/Sorter/NodeInfoSorter.php b/src/Sorter/NodeInfoSorter.php
index f933bd4..4c74983 100644
--- a/src/Sorter/NodeInfoSorter.php
+++ b/src/Sorter/NodeInfoSorter.php
@@ -14,7 +14,10 @@ final class NodeInfoSorter
*/
public function sortNodeInfosByClass(array $nodeInfos): array
{
- usort($nodeInfos, fn (NodeInfo $firstNodeInfo, NodeInfo $secondNodeInfo): int => $firstNodeInfo->getClass() <=> $secondNodeInfo->getClass());
+ usort(
+ $nodeInfos,
+ fn (NodeInfo $firstNodeInfo, NodeInfo $secondNodeInfo): int => $firstNodeInfo->getClass() <=> $secondNodeInfo->getClass()
+ );
return $nodeInfos;
}
diff --git a/tests/NodeInfosFactoryTest.php b/tests/NodeInfosFactoryTest.php
index b818de1..08921be 100644
--- a/tests/NodeInfosFactoryTest.php
+++ b/tests/NodeInfosFactoryTest.php
@@ -4,23 +4,25 @@
namespace Rector\PhpParserNodesDocs\Tests;
+use PhpParser\PrettyPrinter\Standard;
use PHPUnit\Framework\TestCase;
-use Rector\PhpParserNodesDocs\DependencyInjection\ContainerFactory;
+use Rector\PhpParserNodesDocs\Finder\PhpFilesFinder;
+use Rector\PhpParserNodesDocs\NodeCodeSampleProvider;
use Rector\PhpParserNodesDocs\NodeInfosFactory;
+use Rector\PhpParserNodesDocs\Sorter\NodeInfoSorter;
final class NodeInfosFactoryTest extends TestCase
{
public function test(): void
{
- $containerFactory = new ContainerFactory();
- $container = $containerFactory->create();
-
- /** @var NodeInfosFactory $nodeInfosFactory */
- $nodeInfosFactory = $container->make(NodeInfosFactory::class);
+ $nodeInfosFactory = new NodeInfosFactory(
+ new NodeCodeSampleProvider(new Standard(), new PhpFilesFinder()),
+ new NodeInfoSorter()
+ );
$nodeInfos = $nodeInfosFactory->create();
$nodeInfoCount = count($nodeInfos);
- $this->assertGreaterThan(50, $nodeInfoCount);
+ $this->assertGreaterThan(78, $nodeInfoCount);
}
}