Try Rector
Docs
Hire Team
Find Rule
Blog
Contact
AST
Try Rector
Docs
Hire Team
Find Rule
Blog
Contact
AST
Run Rector on your code to see what it can do for you:
// no change
PHP snippet to change
<?php declare(strict_types=1); namespace App\Models\Media; use App\Facades\Thumbnail; use FFMpeg\FFMpeg; use Illuminate\Support\Facades\Storage; class Video extends Media { protected $hidden = [ 'pages', ]; public function createPreview(): void { $ffmpeg = FFMpeg::create(); $video = $ffmpeg->open(Storage::disk('media')->path($this->path)); $atSecond = floor($this->duration / 2); $frame = $video->frame(TimeCode::fromSeconds($atSecond)); $frame->save(Storage::disk('preview')->path($this->path)); } } // I am not able to recreate my issue in this Demo, this is the output from my local run //=================== //1) app/Models/Media/Video.php:17 // ---------- begin diff ---------- //@@ @@ // { // $ffmpeg = FFMpeg::create(); //- /** @var \FFMpeg\Media\Video $video */ //- $video = $ffmpeg->open(Storage::disk('media')->path($this->path)); //+ /** @var \FFMpeg\Media\Video $audio */ //+ $audio = $ffmpeg->open(Storage::disk('media')->path($this->path)); // $atSecond = floor($this->duration / 2); //- $frame = $video->frame(TimeCode::fromSeconds($atSecond)); //+ $frame = $audio->frame(TimeCode::fromSeconds($atSecond)); // $frame->save(Storage::disk('preview')->path($this->path)); // } // ----------- end diff ----------- //Applied rules: // * RenameVariableToMatchMethodCallReturnTypeRector
Config
rector.php
<?php // withSkip and with phpSets creates error in demo => commented out use Rector\Config\RectorConfig; use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; return RectorConfig::configure() // A. whole set ->withPreparedSets( deadCode: true, codeQuality: true, typeDeclarations: true, privatization: true, naming: true, instanceOf: true, earlyReturn: true, carbon: true, rectorPreset: true, ) ->withRootFiles() //->withSkip([ // PostIncDecToPreDecRector::class, //]) //->withPhpSets() ->withCodingStyleLevel(level: 9);
Run Rector
Rector version:
a6f0ce
- released at 2025-12-30 10:02