diff --git a/config/sets/laravel-arrayaccess-to-method-call.php b/config/sets/laravel-arrayaccess-to-method-call.php index e3f27a9f..9ff916e1 100644 --- a/config/sets/laravel-arrayaccess-to-method-call.php +++ b/config/sets/laravel-arrayaccess-to-method-call.php @@ -17,10 +17,26 @@ new ObjectType('Illuminate\Foundation\Application'), 'make', ), + new ArrayDimFetchToMethodCall( + new ObjectType('Illuminate\Contracts\Foundation\Application'), + 'make', + ), new ArrayDimFetchToMethodCall( new ObjectType('Illuminate\Config\Repository'), 'get', ), + new ArrayDimFetchToMethodCall( + new ObjectType('Illuminate\Contracts\Config\Repository'), + 'make', + ), + new ArrayDimFetchToMethodCall( + new ObjectType('Illuminate\Contracts\Container\Container\Application'), + 'make', + ), + new ArrayDimFetchToMethodCall( + new ObjectType('Illuminate\Contracts\Container\Container'), + 'make', + ), ], ); }; diff --git a/pint.json b/pint.json new file mode 100644 index 00000000..a5ba00f7 --- /dev/null +++ b/pint.json @@ -0,0 +1,6 @@ +{ + "rules": { + "single_line_empty_body": false, + "concat_space": false + } +} diff --git a/src/Rector/Class_/ReplaceExpectsMethodsInTestsRector.php b/src/Rector/Class_/ReplaceExpectsMethodsInTestsRector.php index 16667e08..d9cf3a97 100644 --- a/src/Rector/Class_/ReplaceExpectsMethodsInTestsRector.php +++ b/src/Rector/Class_/ReplaceExpectsMethodsInTestsRector.php @@ -74,7 +74,7 @@ public function getNodeTypes(): array } /** - * @param Node\Stmt\Class_ $node + * @param Class_ $node */ public function refactor(Node $node): ?Class_ { diff --git a/src/Rector/Expr/AppEnvironmentComparisonToParameterRector.php b/src/Rector/Expr/AppEnvironmentComparisonToParameterRector.php index 68cb7a23..edcc28d1 100644 --- a/src/Rector/Expr/AppEnvironmentComparisonToParameterRector.php +++ b/src/Rector/Expr/AppEnvironmentComparisonToParameterRector.php @@ -51,7 +51,7 @@ public function refactor(Node $node): MethodCall|StaticCall|null return null; } - /** @var Node\Expr\MethodCall|Node\Expr\StaticCall|null $methodCall */ + /** @var MethodCall|StaticCall|null $methodCall */ $methodCall = array_values( array_filter( [$node->left, $node->right], diff --git a/src/Rector/FuncCall/FactoryFuncCallToStaticCallRector.php b/src/Rector/FuncCall/FactoryFuncCallToStaticCallRector.php index dea4b7e7..3c1609e2 100644 --- a/src/Rector/FuncCall/FactoryFuncCallToStaticCallRector.php +++ b/src/Rector/FuncCall/FactoryFuncCallToStaticCallRector.php @@ -51,7 +51,7 @@ public function getNodeTypes(): array } /** - * @param Node\Expr\FuncCall $node + * @param FuncCall $node */ public function refactor(Node $node): ?Node { diff --git a/src/Rector/FuncCall/SleepFuncToSleepStaticCallRector.php b/src/Rector/FuncCall/SleepFuncToSleepStaticCallRector.php index 950e4a34..3d428376 100644 --- a/src/Rector/FuncCall/SleepFuncToSleepStaticCallRector.php +++ b/src/Rector/FuncCall/SleepFuncToSleepStaticCallRector.php @@ -41,7 +41,7 @@ public function getNodeTypes(): array } /** - * @param Node\Stmt\Expression $node + * @param Expression $node */ public function refactor(Node $node): ?Node { diff --git a/src/Rector/MethodCall/EloquentWhereRelationTypeHintingParameterRector.php b/src/Rector/MethodCall/EloquentWhereRelationTypeHintingParameterRector.php index bf46e3c9..3b863b06 100644 --- a/src/Rector/MethodCall/EloquentWhereRelationTypeHintingParameterRector.php +++ b/src/Rector/MethodCall/EloquentWhereRelationTypeHintingParameterRector.php @@ -95,7 +95,7 @@ private function changeClosureParamType(MethodCall|StaticCall $node): void ['whereHasMorph', 'orWhereHasMorph', 'whereDoesntHaveMorph', 'orWhereDoesntHaveMorph'] ) ? 2 : 1; - /** @var Node\Expr\ArrowFunction|Node\Expr\Closure $closure */ + /** @var ArrowFunction|Closure $closure */ $closure = $node->getArgs()[$position] ->value; diff --git a/src/Rector/MethodCall/EloquentWhereTypeHintClosureParameterRector.php b/src/Rector/MethodCall/EloquentWhereTypeHintClosureParameterRector.php index a98baf59..966cf5dd 100644 --- a/src/Rector/MethodCall/EloquentWhereTypeHintClosureParameterRector.php +++ b/src/Rector/MethodCall/EloquentWhereTypeHintClosureParameterRector.php @@ -76,7 +76,7 @@ private function isWhereMethodWithClosureOrArrowFunction(MethodCall|StaticCall $ private function changeClosureParamType(MethodCall|StaticCall $node): void { - /** @var Node\Expr\ArrowFunction|Node\Expr\Closure $closure */ + /** @var ArrowFunction|Closure $closure */ $closure = $node->getArgs()[0] ->value; diff --git a/src/Rector/MethodCall/RefactorBlueprintGeometryColumnsRector.php b/src/Rector/MethodCall/RefactorBlueprintGeometryColumnsRector.php index 82694a67..b6f72c47 100644 --- a/src/Rector/MethodCall/RefactorBlueprintGeometryColumnsRector.php +++ b/src/Rector/MethodCall/RefactorBlueprintGeometryColumnsRector.php @@ -37,7 +37,7 @@ public function getNodeTypes(): array } /** - * @param Node\Expr\MethodCall $node + * @param MethodCall $node */ public function refactor(Node $node): ?MethodCall { diff --git a/src/Rector/MethodCall/ReplaceWithoutJobsEventsAndNotificationsWithFacadeFakeRector.php b/src/Rector/MethodCall/ReplaceWithoutJobsEventsAndNotificationsWithFacadeFakeRector.php index 90b1eb64..68601ce3 100644 --- a/src/Rector/MethodCall/ReplaceWithoutJobsEventsAndNotificationsWithFacadeFakeRector.php +++ b/src/Rector/MethodCall/ReplaceWithoutJobsEventsAndNotificationsWithFacadeFakeRector.php @@ -43,7 +43,7 @@ public function getNodeTypes(): array } /** - * @param Node\Expr\MethodCall $node + * @param MethodCall $node */ public function refactor(Node $node): ?StaticCall { diff --git a/src/Rector/StaticCall/DispatchToHelperFunctionsRector.php b/src/Rector/StaticCall/DispatchToHelperFunctionsRector.php index 98dbd319..06580362 100644 --- a/src/Rector/StaticCall/DispatchToHelperFunctionsRector.php +++ b/src/Rector/StaticCall/DispatchToHelperFunctionsRector.php @@ -8,6 +8,7 @@ use PhpParser\Node\Expr\New_; use PhpParser\Node\Expr\StaticCall; use PhpParser\Node\Name; +use PhpParser\Node\Name\FullyQualified; use PHPStan\Broker\ClassNotFoundException; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\ReflectionProvider; @@ -128,7 +129,7 @@ private function createDispatchableCall(StaticCall $staticCall, string $method): return new FuncCall( new Name($method), [ - new Arg(new New_(new Name($class), $staticCall->args)), + new Arg(new New_(new FullyQualified($class), $staticCall->args)), ], ); } diff --git a/src/Rector/StaticCall/EloquentMagicMethodToQueryBuilderRector.php b/src/Rector/StaticCall/EloquentMagicMethodToQueryBuilderRector.php index 57df8f3b..7143445c 100644 --- a/src/Rector/StaticCall/EloquentMagicMethodToQueryBuilderRector.php +++ b/src/Rector/StaticCall/EloquentMagicMethodToQueryBuilderRector.php @@ -109,14 +109,14 @@ public function refactor(Node $node): ?Node return null; } - $queryMethodCall = $this->nodeFactory->createStaticCall($originalClassName, 'query'); + $staticCall = $this->nodeFactory->createStaticCall($originalClassName, 'query'); - $newNode = $this->nodeFactory->createMethodCall($queryMethodCall, $methodName); + $methodCall = $this->nodeFactory->createMethodCall($staticCall, $methodName); foreach ($node->args as $arg) { - $newNode->args[] = $arg; + $methodCall->args[] = $arg; } - return $newNode; + return $methodCall; } /** diff --git a/src/Rector/StaticCall/ReplaceAssertTimesSendWithAssertSentTimesRector.php b/src/Rector/StaticCall/ReplaceAssertTimesSendWithAssertSentTimesRector.php index 6f835c1b..71132e25 100644 --- a/src/Rector/StaticCall/ReplaceAssertTimesSendWithAssertSentTimesRector.php +++ b/src/Rector/StaticCall/ReplaceAssertTimesSendWithAssertSentTimesRector.php @@ -35,7 +35,7 @@ public function getNodeTypes(): array } /** - * @param Node\Expr\StaticCall $node + * @param StaticCall $node */ public function refactor(Node $node): ?StaticCall { diff --git a/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/bus_dispatchable.php.inc b/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/bus_dispatchable.php.inc index 959a1d10..7eafc966 100644 --- a/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/bus_dispatchable.php.inc +++ b/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/bus_dispatchable.php.inc @@ -12,4 +12,4 @@ namespace RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\ use RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestJob; -dispatch(new RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestJob('param1', 'param2')); +dispatch(new \RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestJob('param1', 'param2')); diff --git a/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/event_dispatchable.php.inc b/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/event_dispatchable.php.inc index 54bb2480..7469b863 100644 --- a/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/event_dispatchable.php.inc +++ b/tests/Rector/StaticCall/DispatchToHelperFunctionsRector/Fixture/event_dispatchable.php.inc @@ -12,4 +12,4 @@ namespace RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\ use RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestEvent; -event(new RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestEvent('param1', 'param2')); +event(new \RectorLaravel\Tests\Rector\StaticCall\DispatchToHelperFunctionsRector\Source\TestEvent('param1', 'param2'));