1. Go to this page and download the library: Download jcergolj/rector-for-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jcergolj / rector-for-laravel example snippets
public function test_user_can_log_in(): void
{
$user = User::factory()->create();
$this->assertTrue(true);
$this->assertSame('John', $user->name);
}
public function test_user_can_log_in(): void
{
$user = User::factory()->create();
$this->assertTrue(true);
$this->assertSame('John', $user->name);
}
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/**
* @test
*/
public function user_can_log_in(): void
{
}
}
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
#[Test]
public function user_can_log_in(): void
{
}
}
use Jcergolj\RectorForLaravel\CustomRules\WrapLongListsRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withConfiguredRule(WrapLongListsRector::class, [
WrapLongListsRector::MAX_LINE_LENGTH => 120,
]);
use Jcergolj\RectorForLaravel\CustomRules\BlankLineBetweenStatementsRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
BlankLineBetweenStatementsRector::class,
]);
use Jcergolj\RectorForLaravel\CustomRules\WrapLongConcatenationsRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withConfiguredRule(WrapLongConcatenationsRector::class, [
WrapLongConcatenationsRector::MAX_LINE_LENGTH => 120,
]);
if (
$request->routeIs('licence-agreement.create') ||
$request->routeIs('licence-agreement.store') ||
$request->routeIs('download-licence-agreement')
) {
// Existing body unchanged.
}
use Jcergolj\RectorForLaravel\CustomRules\WrapLongBooleanConditionsRector;
return RectorConfig::configure()
->withConfiguredRule(WrapLongBooleanConditionsRector::class, [
WrapLongBooleanConditionsRector::MAX_LINE_LENGTH => 120,
]);
public function test_can_view_tokens(): void
{
$this->get('/tokens')->assertOk();
}
public function test_auth_is_applied(): void
{
$this->get('/tokens')->assertMiddlewareIsApplied('auth');
}
public function test_auth_is_applied(): void
{
$this->get('/tokens')->assertMiddlewareIsApplied('auth');
}
public function test_can_view_tokens(): void
{
$this->get('/tokens')->assertOk();
}
public static function values(): array
{
return [['value']];
}
#[\PHPUnit\Framework\Attributes\DataProvider('values')]
public function test_value(string $value): void
{
$this->assertSame('value', $value);
}
use Jcergolj\RectorForLaravel\CustomRules\DataProviderBeforeTestRector;
use Jcergolj\RectorForLaravel\CustomRules\MiddlewareTestsFirstRector;
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withRules([
MiddlewareTestsFirstRector::class,
DataProviderBeforeTestRector::class,
]);
use Jcergolj\RectorForLaravel\CustomRules\RemoveFillableFromUnguardedModelsRector;
return RectorConfig::configure()
->withRules([
RemoveFillableFromUnguardedModelsRector::class,
]);
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $fillable = [
'name',
'email',
];
}
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
}
use Jcergolj\RectorForLaravel\CustomRules\RemoveMigrationDownMethodRector;
return RectorConfig::configure()
->withRules([
RemoveMigrationDownMethodRector::class,
]);
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
public function up(): void
{
}
public function down(): void
{
}
}
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
public function up(): void
{
}
}