Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
289 changes: 193 additions & 96 deletions README.md

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions bin/dump-nodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

declare(strict_types=1);

use PhpParser\PrettyPrinter\Standard;
use Rector\PhpParserNodesDocs\Finder\PhpFilesFinder;
use Rector\PhpParserNodesDocs\NodeCodeSampleProvider;
use Rector\PhpParserNodesDocs\NodeInfosFactory;
use Rector\PhpParserNodesDocs\Printer\MarkdownNodeInfosPrinter;
Expand All @@ -12,17 +10,15 @@
require_once __DIR__ . '/../vendor/autoload.php';

$markdownNodeInfosPrinter = new MarkdownNodeInfosPrinter();
$nodeInfosFactory = new NodeInfosFactory(
new NodeCodeSampleProvider(new Standard(), new PhpFilesFinder()),
new NodeInfoSorter()
);

$nodeInfosFactory = new NodeInfosFactory(new NodeCodeSampleProvider(), new NodeInfoSorter());

$nodeInfos = $nodeInfosFactory->create();
$printedContent = $markdownNodeInfosPrinter->print($nodeInfos);

file_put_contents(getcwd() . '/README.md', $printedContent);

echo sprintf('<info>Documentation for %d nodes was generated to README.md</info>' . PHP_EOL, count($nodeInfos));
echo sprintf('Documentation for %d nodes was generated to README.md' . PHP_EOL . PHP_EOL, count($nodeInfos));

// success
exit(0);
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"require": {
"php": "^8.3",
"nikic/php-parser": "^5.6",
"webmozart/assert": "^1.11"
"webmozart/assert": "^1.11",
"symfony/finder": "^7.3"
},
"require-dev": {
"symplify/easy-coding-standard": "^12.6",
Expand Down
1 change: 1 addition & 0 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
__DIR__ . '/bin',
__DIR__ . '/src',
__DIR__ . '/tests',
__DIR__ . '/snippet'
])
->withPreparedSets(symplify: true, common: true, psr12: true);
6 changes: 1 addition & 5 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ parameters:
- bin
- src
- tests
- snippet

treatPhpDocTypesAsCertain: false

ignoreErrors:
-
path: src/Finder/PhpFilesFinder.php
identifier: varTag.nativeType
16 changes: 6 additions & 10 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->importNames();

$rectorConfig->paths([
return RectorConfig::configure()
->withImportNames()
->withPaths([
__DIR__ . '/snippet',
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$rectorConfig->sets([
LevelSetList::UP_TO_PHP_81
]);
};
])
->withPhpSets();
4 changes: 2 additions & 2 deletions snippet/alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

use PhpParser\Modifiers;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\TraitUseAdaptation\Alias;

$traitFullyQualified = new FullyQualified('TraitName');

return new Alias($traitFullyQualified, 'method', Class_::MODIFIER_PUBLIC, 'aliasedMethod');
return new Alias($traitFullyQualified, 'method', Modifiers::PUBLIC, 'aliasedMethod');
4 changes: 2 additions & 2 deletions snippet/array_dim_fetch.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use PhpParser\Node\Expr\ArrayDimFetch;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$variable = new Variable('variableName');
$dimension = new LNumber(0);
$dimension = new Int_(0);

return new ArrayDimFetch($variable, $dimension);
6 changes: 3 additions & 3 deletions snippet/assign_op/assign_op_coalesce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\AssignOp\Coalesce;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new Coalesce($left, $right);
6 changes: 3 additions & 3 deletions snippet/assign_op/assign_op_concat.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\AssignOp\Concat;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new Concat($left, $right);
6 changes: 3 additions & 3 deletions snippet/binary_op/binary_op_boolean_and.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\BinaryOp\BooleanAnd;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new BooleanAnd($left, $right);
6 changes: 3 additions & 3 deletions snippet/binary_op/binary_op_coalesce.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\BinaryOp\Coalesce;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new Coalesce($left, $right);
6 changes: 3 additions & 3 deletions snippet/binary_op/binary_op_concat.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\BinaryOp\Concat;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new Concat($left, $right);
6 changes: 3 additions & 3 deletions snippet/binary_op/binary_op_equal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\BinaryOp\Equal;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new Equal($left, $right);
6 changes: 3 additions & 3 deletions snippet/binary_op/binary_op_identical.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\BinaryOp\Identical;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new Identical($left, $right);
6 changes: 3 additions & 3 deletions snippet/binary_op/binary_op_minus.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\BinaryOp\Minus;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new Minus($left, $right);
6 changes: 3 additions & 3 deletions snippet/binary_op/binary_op_not_equal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\BinaryOp\NotEqual;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new NotEqual($left, $right);
6 changes: 3 additions & 3 deletions snippet/binary_op/binary_op_not_identical.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\BinaryOp\NotIdentical;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new NotIdentical($left, $right);
6 changes: 3 additions & 3 deletions snippet/binary_op/binary_op_spaceship.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
declare(strict_types=1);

use PhpParser\Node\Expr\BinaryOp\Spaceship;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;

$left = new LNumber(5);
$right = new LNumber(10);
$left = new Int_(5);
$right = new Int_(10);

return new Spaceship($left, $right);
13 changes: 13 additions & 0 deletions snippet/block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\Int_;
use PhpParser\Node\Stmt\Block;
use PhpParser\Node\Stmt\Expression;

$assign = new Assign(new Variable('someValue'), new Int_(10000));

return new Block([new Expression($assign)]);
4 changes: 2 additions & 2 deletions snippet/class_const.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

use PhpParser\Modifiers;
use PhpParser\Node\Const_;
use PhpParser\Node\Scalar\String_;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassConst;

$defaultValue = new String_('default value');
$const = new Const_('SOME_CLASS_CONSTANT', $defaultValue);

return new ClassConst([$const], Class_::MODIFIER_PUBLIC);
return new ClassConst([$const], Modifiers::PUBLIC);
3 changes: 2 additions & 1 deletion snippet/class_final.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

declare(strict_types=1);

use PhpParser\Modifiers;
use PhpParser\Node\Stmt\Class_;

$class = new Class_('ClassName');
$class->flags |= Class_::MODIFIER_FINAL;
$class->flags |= Modifiers::FINAL;

return $class;
4 changes: 2 additions & 2 deletions snippet/class_method.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

use PhpParser\Node\Stmt\Class_;
use PhpParser\Modifiers;
use PhpParser\Node\Stmt\ClassMethod;

$classMethod = new ClassMethod('methodName');
$classMethod->flags = Class_::MODIFIER_PUBLIC;
$classMethod->flags = Modifiers::PUBLIC;

return $classMethod;
4 changes: 2 additions & 2 deletions snippet/class_method_with_param_and_return_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

use PhpParser\Modifiers;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;

$classMethod = new ClassMethod('methodName');
$classMethod->flags = Class_::MODIFIER_PRIVATE;
$classMethod->flags = Modifiers::PRIVATE;

$param = new Param(new Variable('paramName'));
$classMethod->params = [$param];
Expand Down
8 changes: 4 additions & 4 deletions snippet/class_method_with_stmts.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

declare(strict_types=1);

use PhpParser\Modifiers;
use PhpParser\Node\Expr\Assign;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Scalar\Int_;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Expression;

$classMethod = new ClassMethod('methodName');
$classMethod->flags = Class_::MODIFIER_PUBLIC;
$classMethod->flags = Modifiers::PUBLIC;

$variable = new Variable('some');
$number = new LNumber(10000);
$number = new Int_(10000);
$assign = new Assign($variable, $number);

$classMethod->stmts[] = new Expression($assign);
Expand Down
8 changes: 5 additions & 3 deletions snippet/class_with_property.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

declare(strict_types=1);

use PhpParser\Modifiers;
use PhpParser\Node\Identifier;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\Property;
use PhpParser\Node\Stmt\PropertyProperty;

$class = new Class_('ClassName');
$class = new Class_(new Identifier('ClassName'));

$propertyProperty = new PropertyProperty('someProperty');
$property = new Property(Class_::MODIFIER_PRIVATE, [$propertyProperty]);
$property = new Property(Modifiers::PRIVATE, [$propertyProperty]);

$class->stmts[] = $property;

return $propertyProperty;
return $class;
7 changes: 0 additions & 7 deletions snippet/d_number.php

This file was deleted.

4 changes: 2 additions & 2 deletions snippet/declare.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

declare(strict_types=1);

use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Scalar\Int_;
use PhpParser\Node\Stmt\Declare_;
use PhpParser\Node\Stmt\DeclareDeclare;

$declareDeclare = new DeclareDeclare('strict_types', new LNumber(1));
$declareDeclare = new DeclareDeclare('strict_types', new Int_(1));

return new Declare_([$declareDeclare]);
Loading
Loading