Skip to content

Commit

Permalink
Improvements and set changes
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfox committed Feb 19, 2025
1 parent eabd74f commit ae5b6d7
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
14 changes: 14 additions & 0 deletions config/sets/laravel120.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use RectorLaravel\Rector\MethodCall\ContainerBindConcreteWithClosureOnlyRector;

// see https://laravel.com/docs/12.x/upgrade
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->import(__DIR__ . '/../config.php');

// https://github.com/laravel/framework/pull/54628
$rectorConfig->rule(ContainerBindConcreteWithClosureOnlyRector::class);
};
11 changes: 11 additions & 0 deletions config/sets/level/up-to-laravel-120.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use RectorLaravel\Set\LaravelLevelSetList;
use RectorLaravel\Set\LaravelSetList;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->sets([LaravelSetList::LARAVEL_120, LaravelLevelSetList::UP_TO_LARAVEL_110]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
final class ContainerBindConcreteWithClosureOnlyRector extends AbstractRector
{
public function __construct(
private readonly ReturnTypeInferer $returnTypeInferer,
private readonly StaticTypeMapper $staticTypeMapper,
private readonly ReturnTypeInferer $returnTypeInfer,
private readonly StaticTypeMapper $staticTypeMapper,
) {}

public function getRuleDefinition(): RuleDefinition
Expand Down Expand Up @@ -77,7 +77,7 @@ public function refactor(Node $node): ?MethodCall
if (! $concreteNode instanceof Closure) {
return null;
}
$abstractFromConcrete = $this->returnTypeInferer->inferFunctionLike($concreteNode);
$abstractFromConcrete = $this->returnTypeInfer->inferFunctionLike($concreteNode);

if ($classString instanceof Const_
&& $this->isName($classString, 'class')) {
Expand Down
5 changes: 5 additions & 0 deletions src/Set/LaravelLevelSetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,9 @@ final class LaravelLevelSetList
* @var string
*/
final public const UP_TO_LARAVEL_110 = __DIR__ . '/../../config/sets/level/up-to-laravel-110.php';

/**
* @var string
*/
final public const UP_TO_LARAVEL_120 = __DIR__ . '/../../config/sets/level/up-to-laravel-120.php';
}
5 changes: 5 additions & 0 deletions src/Set/LaravelSetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ final class LaravelSetList
*/
final public const LARAVEL_110 = __DIR__ . '/../../config/sets/laravel110.php';

/**
* @var string
*/
final public const LARAVEL_120 = __DIR__ . '/../../config/sets/laravel120.php';

/**
* @var string
*/
Expand Down

0 comments on commit ae5b6d7

Please sign in to comment.