Skip to content

Commit

Permalink
Migrate even more deprecations Laravel 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
GeniJaho committed Oct 17, 2024
1 parent 5d07152 commit c46b77f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 7 deletions.
26 changes: 25 additions & 1 deletion config/sets/laravel53.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,46 @@
declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Removing\Rector\Class_\RemoveInterfacesRector;
use Rector\Removing\Rector\Class_\RemoveTraitUseRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\Rector\Name\RenameClassRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
use Rector\Transform\ValueObject\StaticCallToFuncCall;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->import(__DIR__ . '/../config.php');

$rectorConfig
->ruleWithConfiguration(RemoveTraitUseRector::class, [
// see https://laravel.com/docs/5.3/upgrade
'Illuminate\Foundation\Auth\Access\AuthorizesResources',
]);

// https://laravel.com/docs/5.3/upgrade#5.2-deprecations
$rectorConfig
->ruleWithConfiguration(RenameMethodRector::class, [
// https://laravel.com/docs/5.3/upgrade#5.2-deprecations
new MethodCallRename('Illuminate\Support\Collection', 'lists', 'pluck'),
new MethodCallRename('Illuminate\Database\Query\Builder', 'lists', 'pluck'),
new MethodCallRename('Illuminate\Database\Eloquent\Collection', 'withHidden', 'makeVisible'),
new MethodCallRename('Illuminate\Database\Eloquent\Model', 'withHidden', 'makeVisible'),
]);

$rectorConfig
->ruleWithConfiguration(RemoveInterfacesRector::class, [
'Illuminate\Contracts\Bus\SelfHandling',
]);

$rectorConfig
->ruleWithConfiguration(RenameClassRector::class, [
'Illuminate\Database\Eloquent\ScopeInterface' => 'Illuminate\Database\Eloquent\Scope',
'Illuminate\View\Expression' => 'Illuminate\Support\HtmlString',
]);

$rectorConfig
->ruleWithConfiguration(StaticCallToFuncCallRector::class, [
new StaticCallToFuncCall('Illuminate\Support\Str', 'randomBytes', 'random_bytes'),
new StaticCallToFuncCall('Illuminate\Support\Str', 'equals', 'hash_equals'),
]);
};
40 changes: 34 additions & 6 deletions tests/Sets/Laravel53/Fixture/fixture.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,50 @@

namespace RectorLaravel\Tests\Sets\Laravel53;

use Illuminate\Support\Collection;

(new Collection())->lists('id');
(new \Illuminate\Support\Collection())->lists('id');
(new \Illuminate\Database\Eloquent\Builder())->lists('id');
(new \Illuminate\Database\Query\Builder())->lists('id');
(new \Illuminate\Database\Eloquent\Collection())->withHidden([]);
(new \Illuminate\Database\Eloquent\Model())->withHidden([]);
\Illuminate\Support\Str::randomBytes(16);
\Illuminate\Support\Str::equals('knownString', 'userInput');

class SomeJob implements \Illuminate\Contracts\Bus\SelfHandling
{
}

class SomeScope implements \Illuminate\Database\Eloquent\ScopeInterface
{
}

class SomeView extends \Illuminate\View\Expression
{
}

?>
-----
<?php

namespace RectorLaravel\Tests\Sets\Laravel53;

use Illuminate\Support\Collection;

(new Collection())->pluck('id');
(new \Illuminate\Support\Collection())->pluck('id');
(new \Illuminate\Database\Eloquent\Builder())->pluck('id');
(new \Illuminate\Database\Query\Builder())->pluck('id');
(new \Illuminate\Database\Eloquent\Collection())->makeVisible([]);
(new \Illuminate\Database\Eloquent\Model())->makeVisible([]);
\random_bytes(16);
\hash_equals('knownString', 'userInput');

class SomeJob
{
}

class SomeScope implements \Illuminate\Database\Eloquent\Scope
{
}

class SomeView extends \Illuminate\Support\HtmlString
{
}

?>

0 comments on commit c46b77f

Please sign in to comment.