Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into fix-json-get-calls-with-route-helper
Browse files Browse the repository at this point in the history
  • Loading branch information
GeniJaho committed Jul 9, 2024
2 parents 42e7785 + c8e28db commit cdfa3b7
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 16 deletions.
16 changes: 16 additions & 0 deletions config/sets/laravel-arrayaccess-to-method-call.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
),
],
);
};
6 changes: 6 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rules": {
"single_line_empty_body": false,
"concat_space": false
}
}
2 changes: 1 addition & 1 deletion src/Rector/Class_/ReplaceExpectsMethodsInTestsRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getNodeTypes(): array
}

/**
* @param Node\Stmt\Class_ $node
* @param Class_ $node
*/
public function refactor(Node $node): ?Class_
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion src/Rector/FuncCall/FactoryFuncCallToStaticCallRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getNodeTypes(): array
}

/**
* @param Node\Expr\FuncCall $node
* @param FuncCall $node
*/
public function refactor(Node $node): ?Node
{
Expand Down
2 changes: 1 addition & 1 deletion src/Rector/FuncCall/SleepFuncToSleepStaticCallRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getNodeTypes(): array
}

/**
* @param Node\Stmt\Expression $node
* @param Expression $node
*/
public function refactor(Node $node): ?Node
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getNodeTypes(): array
}

/**
* @param Node\Expr\MethodCall $node
* @param MethodCall $node
*/
public function refactor(Node $node): ?MethodCall
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getNodeTypes(): array
}

/**
* @param Node\Expr\MethodCall $node
* @param MethodCall $node
*/
public function refactor(Node $node): ?StaticCall
{
Expand Down
3 changes: 2 additions & 1 deletion src/Rector/StaticCall/DispatchToHelperFunctionsRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function getNodeTypes(): array
}

/**
* @param Node\Expr\StaticCall $node
* @param StaticCall $node
*/
public function refactor(Node $node): ?StaticCall
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

0 comments on commit cdfa3b7

Please sign in to comment.