PHP code example of kapersoft / awesome-rector-rules

1. Go to this page and download the library: Download kapersoft/awesome-rector-rules 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/ */

    

kapersoft / awesome-rector-rules example snippets


use Kapersoft\AwesomeRectorRules\NullableTypeToUnionTypeRector;
use Kapersoft\AwesomeRectorRules\MoveNullToEndOfUnionTypeRector;

return static function (Rector\Config\RectorConfig $rectorConfig): void {
    $rectorConfig->rules([
        NullableTypeToUnionTypeRector::class,
        MoveNullToEndOfUnionTypeRector::class,
    ]);
};

function someFunction(?int $value): ?string
{
    return null;
}

function someFunction(int|null $value): string|null
{
    return null;
}

function someFunction(null|string $param): null|int
{
}

function someFunction(string|null $param): int|null
{
}