diff --git a/config/set/php81.php b/config/set/php81.php index 9d9cfcdaf4e..4ec7f14cd08 100644 --- a/config/set/php81.php +++ b/config/set/php81.php @@ -6,7 +6,7 @@ use Rector\CodingStyle\Rector\FuncCall\FunctionFirstClassCallableRector; use Rector\CodingStyle\Rector\FunctionLike\FunctionLikeToFirstClassCallableRector; use Rector\Config\RectorConfig; -use Rector\Php81\Rector\Array_\FirstClassCallableRector; +use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector; use Rector\Php81\Rector\Class_\MyCLabsClassToEnumRector; use Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector; use Rector\Php81\Rector\ClassMethod\NewInInitializerRector; @@ -31,7 +31,7 @@ NullToStrictStringFuncCallArgRector::class, NullToStrictIntPregSlitFuncCallLimitArgRector::class, // array of local method call - FirstClassCallableRector::class, + ArrayToFirstClassCallableRector::class, // closure/arrow function FunctionLikeToFirstClassCallableRector::class, ClosureFromCallableToFirstClassCallableRector::class, diff --git a/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/FirstClassCallableRectorTest.php b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/ArrayToFirstClassCallableRectorTest.php similarity index 77% rename from rules-tests/Php81/Rector/Array_/FirstClassCallableRector/FirstClassCallableRectorTest.php rename to rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/ArrayToFirstClassCallableRectorTest.php index 4544cb6763b..a8e18eece44 100644 --- a/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/FirstClassCallableRectorTest.php +++ b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/ArrayToFirstClassCallableRectorTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector; +namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector; use Iterator; use PHPUnit\Framework\Attributes\DataProvider; use Rector\Testing\PHPUnit\AbstractRectorTestCase; -final class FirstClassCallableRectorTest extends AbstractRectorTestCase +final class ArrayToFirstClassCallableRectorTest extends AbstractRectorTestCase { #[DataProvider('provideData')] public function test(string $filePath): void diff --git a/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/make_other_closure_pass.php.inc b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/make_other_closure_pass.php.inc similarity index 59% rename from rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/make_other_closure_pass.php.inc rename to rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/make_other_closure_pass.php.inc index 63e5d13a313..f125926e8bd 100644 --- a/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/make_other_closure_pass.php.inc +++ b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/make_other_closure_pass.php.inc @@ -1,9 +1,9 @@ services() @@ -14,10 +14,10 @@ return static function (stdClass $container): void { ----- services() diff --git a/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/skip_dynamic_variable2.php.inc b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_dynamic_variable2.php.inc similarity index 54% rename from rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/skip_dynamic_variable2.php.inc rename to rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_dynamic_variable2.php.inc index c0528525757..31112d81b14 100644 --- a/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/skip_dynamic_variable2.php.inc +++ b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_dynamic_variable2.php.inc @@ -1,6 +1,6 @@ null, -); \ No newline at end of file +); diff --git a/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_attribute_class.php.inc b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_attribute_class.php.inc new file mode 100644 index 00000000000..166946693a8 --- /dev/null +++ b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_attribute_class.php.inc @@ -0,0 +1,8 @@ +name('verification.notice'); diff --git a/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/skip_non_existing_method.php.inc b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_non_existing_method.php.inc similarity index 65% rename from rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/skip_non_existing_method.php.inc rename to rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_non_existing_method.php.inc index ca2d3686e49..3538905b777 100644 --- a/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/skip_non_existing_method.php.inc +++ b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_non_existing_method.php.inc @@ -1,6 +1,6 @@ rule(FirstClassCallableRector::class); + $rectorConfig->rule(ArrayToFirstClassCallableRector::class); $rectorConfig->phpVersion(PhpVersion::PHP_81); }; diff --git a/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/skip_dynamic_variable.php.inc b/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/skip_dynamic_variable.php.inc deleted file mode 100644 index 8665f32f1a8..00000000000 --- a/rules-tests/Php81/Rector/Array_/FirstClassCallableRector/Fixture/skip_dynamic_variable.php.inc +++ /dev/null @@ -1,6 +0,0 @@ -name('verification.notice'); diff --git a/rules/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector.php b/rules/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector.php index 14a77a57aee..fdcedda052a 100644 --- a/rules/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector.php +++ b/rules/CodingStyle/Rector/FunctionLike/FunctionLikeToFirstClassCallableRector.php @@ -22,9 +22,6 @@ use PhpParser\NodeVisitor; use PHPStan\Analyser\Scope; use PHPStan\Reflection\Annotations\AnnotationMethodReflection; -use PHPStan\Reflection\Native\NativeFunctionReflection; -use PHPStan\Reflection\ParametersAcceptorSelector; -use PHPStan\Type\CallableType; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PhpParser\AstResolver; use Rector\PHPStan\ScopeFetcher; @@ -40,11 +37,6 @@ */ final class FunctionLikeToFirstClassCallableRector extends AbstractRector implements MinPhpVersionInterface { - /** - * @var string - */ - private const HAS_CALLBACK_SIGNATURE_MULTI_PARAMS = 'has_callback_signature_multi_params'; - public function __construct( private readonly AstResolver $astResolver, private readonly ReflectionResolver $reflectionResolver @@ -72,44 +64,14 @@ function ($parameter) { public function getNodeTypes(): array { - return [CallLike::class, ArrowFunction::class, Closure::class]; + return [ArrowFunction::class, Closure::class]; } /** - * @param CallLike|ArrowFunction|Closure $node + * @param ArrowFunction|Closure $node */ public function refactor(Node $node): null|CallLike { - if ($node instanceof CallLike) { - if ($node->isFirstClassCallable()) { - return null; - } - - $methodReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($node); - foreach ($node->getArgs() as $arg) { - if (! $arg->value instanceof Closure && ! $arg->value instanceof ArrowFunction) { - continue; - } - - if ($methodReflection instanceof NativeFunctionReflection) { - $parametersAcceptors = ParametersAcceptorSelector::combineAcceptors( - $methodReflection->getVariants() - ); - foreach ($parametersAcceptors->getParameters() as $extendedParameterReflection) { - if ($extendedParameterReflection->getType() instanceof CallableType && $extendedParameterReflection->getType()->isVariadic()) { - $arg->value->setAttribute(self::HAS_CALLBACK_SIGNATURE_MULTI_PARAMS, true); - } - } - - return null; - } - - $arg->value->setAttribute(self::HAS_CALLBACK_SIGNATURE_MULTI_PARAMS, true); - } - - return null; - } - $callLike = $this->extractCallLike($node); if ($callLike === null) { return null; @@ -169,7 +131,7 @@ private function shouldSkip( return true; } - if ($node->getAttribute(self::HAS_CALLBACK_SIGNATURE_MULTI_PARAMS) === true) { + if ($node->getAttribute(AttributeKey::HAS_CLOSURE_WITH_VARIADIC_ARGS) === true) { return true; } diff --git a/rules/Php81/Rector/Array_/FirstClassCallableRector.php b/rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php similarity index 95% rename from rules/Php81/Rector/Array_/FirstClassCallableRector.php rename to rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php index 24a9c77d1f1..6af80bbb1f6 100644 --- a/rules/Php81/Rector/Array_/FirstClassCallableRector.php +++ b/rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php @@ -29,9 +29,9 @@ /** * @see RFC https://wiki.php.net/rfc/first_class_callable_syntax - * @see \Rector\Tests\Php81\Rector\Array_\FirstClassCallableRector\FirstClassCallableRectorTest + * @see \Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\ArrayToFirstClassCallableRectorTest */ -final class FirstClassCallableRector extends AbstractRector implements MinPhpVersionInterface +final class ArrayToFirstClassCallableRector extends AbstractRector implements MinPhpVersionInterface { public function __construct( private readonly ArrayCallableMethodMatcher $arrayCallableMethodMatcher, diff --git a/src/DependencyInjection/LazyContainerFactory.php b/src/DependencyInjection/LazyContainerFactory.php index 5065871eae1..b86956123f3 100644 --- a/src/DependencyInjection/LazyContainerFactory.php +++ b/src/DependencyInjection/LazyContainerFactory.php @@ -96,18 +96,6 @@ use Rector\NodeTypeResolver\NodeTypeResolver\ScalarTypeResolver; use Rector\NodeTypeResolver\NodeTypeResolver\StaticCallMethodCallTypeResolver; use Rector\NodeTypeResolver\NodeTypeResolver\TraitTypeResolver; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\ArgNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\AssignedToNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\ByRefReturnNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\ByRefVariableNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\ClassConstFetchNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\ContextNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\GlobalVariableNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\NameNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\PhpVersionConditionNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\PropertyOrClassConstDefaultNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\StaticVariableNodeVisitor; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\SymfonyClosureNodeVisitor; use Rector\NodeTypeResolver\PHPStan\Scope\PHPStanNodeScopeResolver; use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider; use Rector\Php80\AttributeDecorator\DoctrineConverterAttributeDecorator; @@ -128,6 +116,19 @@ use Rector\PhpParser\Comparing\NodeComparator; use Rector\PhpParser\Node\NodeFactory; use Rector\PhpParser\NodeTraverser\RectorNodeTraverser; +use Rector\PhpParser\NodeVisitor\ArgNodeVisitor; +use Rector\PhpParser\NodeVisitor\AssignedToNodeVisitor; +use Rector\PhpParser\NodeVisitor\ByRefReturnNodeVisitor; +use Rector\PhpParser\NodeVisitor\ByRefVariableNodeVisitor; +use Rector\PhpParser\NodeVisitor\ClassConstFetchNodeVisitor; +use Rector\PhpParser\NodeVisitor\ClosureWithVariadicParametersNodeVisitor; +use Rector\PhpParser\NodeVisitor\ContextNodeVisitor; +use Rector\PhpParser\NodeVisitor\GlobalVariableNodeVisitor; +use Rector\PhpParser\NodeVisitor\NameNodeVisitor; +use Rector\PhpParser\NodeVisitor\PhpVersionConditionNodeVisitor; +use Rector\PhpParser\NodeVisitor\PropertyOrClassConstDefaultNodeVisitor; +use Rector\PhpParser\NodeVisitor\StaticVariableNodeVisitor; +use Rector\PhpParser\NodeVisitor\SymfonyClosureNodeVisitor; use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper; use Rector\PHPStanStaticTypeMapper\TypeMapper\AccessoryLiteralStringTypeMapper; @@ -241,6 +242,7 @@ final class LazyContainerFactory */ private const DECORATING_NODE_VISITOR_CLASSES = [ ArgNodeVisitor::class, + ClosureWithVariadicParametersNodeVisitor::class, PhpVersionConditionNodeVisitor::class, AssignedToNodeVisitor::class, SymfonyClosureNodeVisitor::class, diff --git a/src/NodeTypeResolver/Node/AttributeKey.php b/src/NodeTypeResolver/Node/AttributeKey.php index 46f9c922463..a920e187b46 100644 --- a/src/NodeTypeResolver/Node/AttributeKey.php +++ b/src/NodeTypeResolver/Node/AttributeKey.php @@ -282,4 +282,6 @@ final class AttributeKey public const CLASS_CONST_FETCH_NAME = 'class_const_fetch_name'; public const PHP_VERSION_CONDITIONED = 'php_version_conditioned'; + + public const HAS_CLOSURE_WITH_VARIADIC_ARGS = 'has_closure_with_variadic_args'; } diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ArgNodeVisitor.php b/src/PhpParser/NodeVisitor/ArgNodeVisitor.php similarity index 93% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ArgNodeVisitor.php rename to src/PhpParser/NodeVisitor/ArgNodeVisitor.php index c6941070fa1..c539f208310 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ArgNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/ArgNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/AssignedToNodeVisitor.php b/src/PhpParser/NodeVisitor/AssignedToNodeVisitor.php similarity index 96% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/AssignedToNodeVisitor.php rename to src/PhpParser/NodeVisitor/AssignedToNodeVisitor.php index 6bab84300a7..45347398457 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/AssignedToNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/AssignedToNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\ArrayItem; diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ByRefReturnNodeVisitor.php b/src/PhpParser/NodeVisitor/ByRefReturnNodeVisitor.php similarity index 96% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ByRefReturnNodeVisitor.php rename to src/PhpParser/NodeVisitor/ByRefReturnNodeVisitor.php index c77293cd376..158874a2075 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ByRefReturnNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/ByRefReturnNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\FunctionLike; diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ByRefVariableNodeVisitor.php b/src/PhpParser/NodeVisitor/ByRefVariableNodeVisitor.php similarity index 98% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ByRefVariableNodeVisitor.php rename to src/PhpParser/NodeVisitor/ByRefVariableNodeVisitor.php index 1ebe2f2747f..562ba48f8ad 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ByRefVariableNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/ByRefVariableNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\Expr; diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ClassConstFetchNodeVisitor.php b/src/PhpParser/NodeVisitor/ClassConstFetchNodeVisitor.php similarity index 92% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ClassConstFetchNodeVisitor.php rename to src/PhpParser/NodeVisitor/ClassConstFetchNodeVisitor.php index 180a4df876c..3d9e66587dc 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ClassConstFetchNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/ClassConstFetchNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\Expr\ClassConstFetch; diff --git a/src/PhpParser/NodeVisitor/ClosureWithVariadicParametersNodeVisitor.php b/src/PhpParser/NodeVisitor/ClosureWithVariadicParametersNodeVisitor.php new file mode 100644 index 00000000000..0d9cb1ca054 --- /dev/null +++ b/src/PhpParser/NodeVisitor/ClosureWithVariadicParametersNodeVisitor.php @@ -0,0 +1,70 @@ +isFirstClassCallable()) { + return null; + } + + if ($node->getArgs() === []) { + return null; + } + + $methodReflection = $this->reflectionResolver->resolveFunctionLikeReflectionFromCall($node); + + foreach ($node->getArgs() as $arg) { + if (! $arg->value instanceof Closure && ! $arg->value instanceof ArrowFunction) { + continue; + } + + if ($methodReflection instanceof NativeFunctionReflection) { + $parametersAcceptors = ParametersAcceptorSelector::combineAcceptors( + $methodReflection->getVariants() + ); + + foreach ($parametersAcceptors->getParameters() as $extendedParameterReflection) { + if ($extendedParameterReflection->getType() instanceof CallableType && $extendedParameterReflection->getType() ->isVariadic()) { + $arg->value->setAttribute(AttributeKey::HAS_CLOSURE_WITH_VARIADIC_ARGS, true); + } + } + + return null; + } + + $arg->value->setAttribute(AttributeKey::HAS_CLOSURE_WITH_VARIADIC_ARGS, true); + } + + return null; + } +} diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ContextNodeVisitor.php b/src/PhpParser/NodeVisitor/ContextNodeVisitor.php similarity index 98% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ContextNodeVisitor.php rename to src/PhpParser/NodeVisitor/ContextNodeVisitor.php index 0785dcd718c..2370ad29014 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ContextNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/ContextNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\Arg; diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/GlobalVariableNodeVisitor.php b/src/PhpParser/NodeVisitor/GlobalVariableNodeVisitor.php similarity index 97% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/GlobalVariableNodeVisitor.php rename to src/PhpParser/NodeVisitor/GlobalVariableNodeVisitor.php index 3a71925d89b..f872d0c4279 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/GlobalVariableNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/GlobalVariableNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\Expr; diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/NameNodeVisitor.php b/src/PhpParser/NodeVisitor/NameNodeVisitor.php similarity index 95% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/NameNodeVisitor.php rename to src/PhpParser/NodeVisitor/NameNodeVisitor.php index 3ef20792238..5fbd56bb35f 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/NameNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/NameNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\Expr\ConstFetch; diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/PhpVersionConditionNodeVisitor.php b/src/PhpParser/NodeVisitor/PhpVersionConditionNodeVisitor.php similarity index 96% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/PhpVersionConditionNodeVisitor.php rename to src/PhpParser/NodeVisitor/PhpVersionConditionNodeVisitor.php index b81f526c00d..8fb36770664 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/PhpVersionConditionNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/PhpVersionConditionNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\Expr\FuncCall; diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/PropertyOrClassConstDefaultNodeVisitor.php b/src/PhpParser/NodeVisitor/PropertyOrClassConstDefaultNodeVisitor.php similarity index 95% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/PropertyOrClassConstDefaultNodeVisitor.php rename to src/PhpParser/NodeVisitor/PropertyOrClassConstDefaultNodeVisitor.php index 4ac38b7dccc..e4ca8759d47 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/PropertyOrClassConstDefaultNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/PropertyOrClassConstDefaultNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\Expr; diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StaticVariableNodeVisitor.php b/src/PhpParser/NodeVisitor/StaticVariableNodeVisitor.php similarity index 97% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StaticVariableNodeVisitor.php rename to src/PhpParser/NodeVisitor/StaticVariableNodeVisitor.php index b82bc59e391..43829b955b5 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StaticVariableNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/StaticVariableNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\Expr; diff --git a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/SymfonyClosureNodeVisitor.php b/src/PhpParser/NodeVisitor/SymfonyClosureNodeVisitor.php similarity index 94% rename from src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/SymfonyClosureNodeVisitor.php rename to src/PhpParser/NodeVisitor/SymfonyClosureNodeVisitor.php index bcdd423c138..d6df91cb96c 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/NodeVisitor/SymfonyClosureNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/SymfonyClosureNodeVisitor.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor; +namespace Rector\PhpParser\NodeVisitor; use PhpParser\Node; use PhpParser\Node\Expr\Closure; diff --git a/src/PhpParser/Parser/SimplePhpParser.php b/src/PhpParser/Parser/SimplePhpParser.php index 6520ea2baed..b1afa8cf229 100644 --- a/src/PhpParser/Parser/SimplePhpParser.php +++ b/src/PhpParser/Parser/SimplePhpParser.php @@ -10,7 +10,7 @@ use PhpParser\NodeTraverser; use PhpParser\Parser; use PhpParser\ParserFactory; -use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\AssignedToNodeVisitor; +use Rector\PhpParser\NodeVisitor\AssignedToNodeVisitor; use Throwable; final readonly class SimplePhpParser diff --git a/tests/Issues/AnnotationToAttributeFirstClassCallable/config/configured_rule.php b/tests/Issues/AnnotationToAttributeFirstClassCallable/config/configured_rule.php index 4b6f2fc07c6..6dd284d96e8 100644 --- a/tests/Issues/AnnotationToAttributeFirstClassCallable/config/configured_rule.php +++ b/tests/Issues/AnnotationToAttributeFirstClassCallable/config/configured_rule.php @@ -5,10 +5,10 @@ use Rector\Config\RectorConfig; use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; use Rector\Php80\ValueObject\AnnotationToAttribute; -use Rector\Php81\Rector\Array_\FirstClassCallableRector; +use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector; return RectorConfig::configure() ->withConfiguredRule(AnnotationToAttributeRector::class, [ new AnnotationToAttribute('Symfony\Component\Serializer\Annotation\Context'), ]) - ->withRules([FirstClassCallableRector::class]); + ->withRules([ArrayToFirstClassCallableRector::class]); diff --git a/tests/Issues/AttributeAndArgValueRefresh/config/configured_rule.php b/tests/Issues/AttributeAndArgValueRefresh/config/configured_rule.php index 72c1632c059..a709ea2c910 100644 --- a/tests/Issues/AttributeAndArgValueRefresh/config/configured_rule.php +++ b/tests/Issues/AttributeAndArgValueRefresh/config/configured_rule.php @@ -3,7 +3,7 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Php81\Rector\Array_\FirstClassCallableRector; +use Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector; use Rector\Tests\Issues\AttributeAndArgValueRefresh\Source\SetArrayArgValueRector; use Rector\Tests\Issues\AttributeAndArgValueRefresh\Source\SetArrayAttributeValueRector; @@ -11,5 +11,5 @@ ->withRules([ SetArrayArgValueRector::class, SetArrayAttributeValueRector::class, - FirstClassCallableRector::class, + ArrayToFirstClassCallableRector::class, ]);