PHP code example of palpalani / grumphp-rector-task

1. Go to this page and download the library: Download palpalani/grumphp-rector-task 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/ */

    

palpalani / grumphp-rector-task example snippets




declare(strict_types=1);

use Rector\Core\Configuration\Option;
use Rector\Set\ValueObject\SetList;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->parallel();

    $rectorConfig->paths([
        __DIR__ . '/app',
        __DIR__ . '/config',
        __DIR__ . '/database',
        __DIR__ . '/tests'
        __DIR__ . '/routes',
    ]);

    $rectorConfig->skip([
        IssetOnPropertyObjectToPropertyExistsRector::class,

        __DIR__ . '/app/Http/Middleware/*',
    ]);

    $rectorConfig->rules([
        ReturnTypeFromStrictBoolReturnExprRector::class,
        //ReturnTypeFromStrictNativeFuncCallRector::class,
        ReturnTypeFromStrictNewArrayRector::class,
        ReturnTypeFromStrictScalarReturnExprRector::class,
        ReturnTypeFromReturnNewRector::class,
    ]);

    $rectorConfig->sets([
        SetList::CODE_QUALITY,
        SetList::CODING_STYLE,
        SetList::DEAD_CODE,
        SetList::TYPE_DECLARATION,
        SetList::EARLY_RETURN,
        SetList::PHP_81,
        LevelSetList::UP_TO_PHP_80,
    ]);

    $rectorConfig->sets([
        LaravelSetList::LARAVEL_CODE_QUALITY,
        LaravelSetList::LARAVEL_90,
        LaravelLevelSetList::UP_TO_LARAVEL_80,
    ]);
};