Try Rector
Docs
Hire Team
Find Rule
Blog
Contact
AST
Try Rector
Docs
Hire Team
Find Rule
Blog
Contact
AST
Rector run Failed:
{ "totals": { "changed_files": 0, "errors": 1 }, "errors": [ { "message": "System error: \"Call to undefined method Rector\\PhpParser\\Printer\\BetterStandardPrinter::pPHPStan_Node_AlwaysRememberedExpr()\"\nRun Rector with \"--debug\" option and post the report here: https://github.com/rectorphp/rector/issues/new", "file": "/var/www/src/../storage/demo/0bj3slmoug9p0b72g9e6/rector_analyzed_file.php", "line": 487 } ] }
Run Rector on your code to see what it can do for you:
PHP snippet to change
<?php namespace App\JsonApi; use App\JsonApi\Types\BaseItem; use Exception; use GuzzleHttp\Exception\GuzzleException; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; use JsonException; class Compare { /** * @throws GuzzleException * @throws JsonException */ public function getMissingDatabaseColumns(): array { $columns = $this->databaseColumns() ?? []; $creator = new Creator($this->getType(), $this->endpointName); $cleanedList = ['id' => true, ...$creator->getSchemaCleanedAttributes(), ...$creator->getSchemaCleanedRelations()]; $ignoreList = $this->itemClass()?->ignoredAttributes() ?? []; $missingCleanedColumns = array_diff_key($cleanedList, array_flip($columns), array_flip($ignoreList)); return collect($missingCleanedColumns) ->map(function ($column, $key) { switch ($key) { case 'id': return "{$key}:id"; case 'uuid': return "{$key}:uuid:unique"; case 'uri': return "{$key}:string:unique"; default: if (! empty($column['asJson'])) { return "{$key}:json:nullable"; } $tableName = Str::of($key)->plural()->snake()->__toString(); return match ($column['type']) { 'array', 'object' => "{$key}:json:nullable", 'boolean' => "{$key}:boolean:default(".(empty($column['default']) ? 'false' : 'true').')', 'hasOne' => "{$key}_id:foreignId:nullable:constrained({$tableName}):nullOnDelete", 'morphTo' => "{$key}:morphs", 'hasMany', 'morphToMany' => null, default => "{$key}:{$column['type']}:nullable", }; } }) ->filter() ->all(); } }
Config
rector.php
<?php declare(strict_types=1); use Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector; use Rector\Config\RectorConfig; return RectorConfig::configure() ->withRules([OptionalParametersAfterRequiredRector::class]);
Run Rector
Rector version:
e040c5
- released at 2026-01-11 00:45