File size: 97,347 Bytes
6648d93
 
 
 
 
1
2
3
4
5
6
{"repo_name": "essentials", "file_name": "/essentials/src/EssentialsServiceProvider.php", "inference_info": {"prefix_code": "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\ServiceProvider as BaseServiceProvider;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\n/**\n * @internal\n */\n", "suffix_code": "\n", "middle_code": "final class EssentialsServiceProvider extends BaseServiceProvider\n{\n    private array $configurables = [\n        Configurables\\AggressivePrefetching::class,\n        Configurables\\AutomaticallyEagerLoadRelationships::class,\n        Configurables\\FakeSleep::class,\n        Configurables\\ForceScheme::class,\n        Configurables\\ImmutableDates::class,\n        Configurables\\PreventStrayRequests::class,\n        Configurables\\ProhibitDestructiveCommands::class,\n        Configurables\\SetDefaultPassword::class,\n        Configurables\\ShouldBeStrict::class,\n        Configurables\\Unguard::class,\n    ];\n    private array $commandsList = [\n        Commands\\EssentialsRectorCommand::class,\n        Commands\\EssentialsPintCommand::class,\n        Commands\\MakeActionCommand::class,\n    ];\n    public function boot(): void\n    {\n        collect($this->configurables)\n            ->map(fn (string $configurable) => $this->app->make($configurable))\n            ->filter(fn (Configurable $configurable): bool => $configurable->enabled())\n            ->each(fn (Configurable $configurable) => $configurable->configure());\n        if ($this->app->runningInConsole()) {\n            $this->commands($this->commandsList);\n            $this->publishes([\n                __DIR__.'/../stubs' => $this->app->basePath('stubs'),\n            ], 'essentials-stubs');\n            $this->publishes([\n                __DIR__.'/../config/essentials.php' => config_path('essentials.php'),\n            ]);\n        }\n    }\n}", "code_description": null, "fill_type": "CLASS_TYPE", "language_type": "php", "sub_task_type": null}, "context_code": [["/essentials/src/Commands/MakeActionCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\GeneratorCommand;\nuse Illuminate\\Support\\Str;\n\nfinal class MakeActionCommand extends GeneratorCommand\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $name = 'make:action';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'Create a new action class';\n\n    /**\n     * The type of class being generated.\n     *\n     * @var string\n     */\n    protected $type = 'Action';\n\n    /**\n     * Execute the console command.\n     *\n     * @return bool|int|null\n     */\n    public function handle()\n    {\n        // First check if the class already exists\n        if ($this->alreadyExists($this->getNameInput())) {\n            $this->error($this->type.' already exists!');\n\n            return 1;\n        }\n\n        return parent::handle();\n    }\n\n    /**\n     * Get the name input.\n     */\n    protected function getNameInput(): string\n    {\n        /** @var string $name */\n        $name = $this->argument('name');\n\n        return Str::of(mb_trim($name))\n            ->replaceEnd('.php', '')\n            ->replaceEnd('Action', '')\n            ->append('Action')\n            ->toString();\n    }\n\n    /**\n     * Get the stub file for the generator.\n     */\n    protected function getStub(): string\n    {\n        return $this->resolveStubPath('/stubs/action.stub');\n    }\n\n    /**\n     * Get the default namespace for the class.\n     */\n    protected function getDefaultNamespace($rootNamespace): string\n    {\n        return $rootNamespace.'\\Actions';\n    }\n\n    /**\n     * Get the destination class path.\n     */\n    protected function getPath($name): string\n    {\n        $name = Str::replaceFirst($this->rootNamespace(), '', $name);\n\n        // Use the app_path helper to get the correct path\n        return app_path(str_replace('\\\\', '/', $name).'.php');\n    }\n\n    /**\n     * Resolve the fully-qualified path to the stub.\n     */\n    private function resolveStubPath(string $stub): string\n    {\n        $basePath = $this->laravel->basePath(mb_trim($stub, '/'));\n\n        return file_exists($basePath)\n            ? $basePath\n            : __DIR__.'/../../'.$stub;\n    }\n}\n"], ["/essentials/src/Commands/EssentialsRectorCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Facades\\File;\n\nfinal class EssentialsRectorCommand extends Command\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $signature = 'essentials:rector\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing rector.php}';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'This command will publish an opinionated Rector configuration file for your project.';\n\n    /**\n     * Execute the console command.\n     */\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Rector configuration file? This will override the existing [rector.php] file.', true)) {\n            return 0;\n        }\n\n        $stub_path = __DIR__.'/../../stubs/rector.stub';\n        $destination_path = base_path('rector.php');\n\n        if (! File::exists($stub_path)) {\n            $this->components->error('Rector configuration stub file not found.');\n\n            return 1;\n        }\n\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n\n        $this->components->info('Publishing Rector configuration file...');\n\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Rector configuration file.');\n\n            return 1;\n        }\n\n        $this->components->info('Rector configuration file published successfully at: '.$destination_path);\n\n        return 0;\n    }\n}\n"], ["/essentials/src/Commands/EssentialsPintCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Facades\\File;\n\nfinal class EssentialsPintCommand extends Command\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $signature = 'essentials:pint\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing pint.json}';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'This command will publish an opinionated Pint configuration file for your project.';\n\n    /**\n     * Execute the console command.\n     */\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Pint configuration file? This will override the existing [pint.json] file.', true)) {\n            return 0;\n        }\n\n        $stub_path = __DIR__.'/../../stubs/pint.stub';\n        $destination_path = base_path('pint.json');\n\n        if (! File::exists($stub_path)) {\n            $this->components->error('Pint configuration stub file not found.');\n\n            return 1;\n        }\n\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n\n        $this->components->info('Publishing Pint configuration file...');\n\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Pint configuration file.');\n\n            return 1;\n        }\n\n        $this->components->info('Pint configuration file published successfully at: '.$destination_path);\n\n        return 0;\n    }\n}\n"], ["/essentials/rector.php", "<?php\n\ndeclare(strict_types=1);\n\nuse Rector\\Config\\RectorConfig;\nuse Rector\\Php83\\Rector\\ClassMethod\\AddOverrideAttributeToOverriddenMethodsRector;\n\nreturn RectorConfig::configure()\n    ->withPaths([\n        __DIR__.'/src',\n        __DIR__.'/tests',\n    ])\n    ->withSkip([\n        AddOverrideAttributeToOverriddenMethodsRector::class,\n    ])\n    ->withPreparedSets(\n        deadCode: true,\n        codeQuality: true,\n        typeDeclarations: true,\n        privatization: true,\n        earlyReturn: true,\n        strictBooleans: true,\n    )\n    ->withPhpSets();\n"], ["/essentials/src/Configurables/AutomaticallyEagerLoadRelationships.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class AutomaticallyEagerLoadRelationships implements Configurable\n{\n    public function __construct(\n        private string $modelClass = Model::class\n    ) {}\n\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        if (! method_exists($this->modelClass, 'automaticallyEagerLoadRelationships')) {\n            return;\n        }\n\n        Model::automaticallyEagerLoadRelationships();\n    }\n}\n"], ["/essentials/src/Configurables/SetDefaultPassword.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Validation\\Rules\\Password;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal class SetDefaultPassword implements Configurable\n{\n    /**\n     * {@inheritDoc}\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    public function configure(): void\n    {\n        Password::defaults(fn (): ?Password => app()->isProduction() ? Password::min(12)->max(255)->uncompromised() : null);\n    }\n}\n"], ["/essentials/src/Configurables/PreventStrayRequests.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\Http;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class PreventStrayRequests implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        $enabled = config()->boolean(sprintf('essentials.%s', self::class), true);\n        $testing = app()->runningUnitTests();\n\n        return $enabled && $testing;\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Http::preventStrayRequests();\n    }\n}\n"], ["/essentials/src/Configurables/FakeSleep.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Sleep;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class FakeSleep implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        $enabled = config()->boolean(sprintf('essentials.%s', self::class), true);\n        $testing = app()->runningUnitTests();\n\n        return $enabled && $testing;\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Sleep::fake();\n    }\n}\n"], ["/essentials/src/Configurables/ProhibitDestructiveCommands.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\DB;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ProhibitDestructiveCommands implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        DB::prohibitDestructiveCommands(\n            app()->isProduction(),\n        );\n    }\n}\n"], ["/essentials/src/Configurables/ImmutableDates.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Support\\Facades\\Date;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ImmutableDates implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Date::use(CarbonImmutable::class);\n    }\n}\n"], ["/essentials/src/Configurables/AggressivePrefetching.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\Vite;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class AggressivePrefetching implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Vite::useAggressivePrefetching();\n    }\n}\n"], ["/essentials/src/Configurables/ForceScheme.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\URL;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ForceScheme implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        URL::forceHttps();\n    }\n}\n"], ["/essentials/src/Configurables/ShouldBeStrict.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ShouldBeStrict implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Model::shouldBeStrict();\n    }\n}\n"], ["/essentials/src/Configurables/Unguard.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class Unguard implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), false);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Model::unguard();\n    }\n}\n"], ["/essentials/src/Contracts/Configurable.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Contracts;\n\n/**\n * @internal\n */\ninterface Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool;\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void;\n}\n"]], "task_instance_info": {"created_time": "2025-08-20 21:14:06", "created_task_model": "DeepSeek-R1", "class_skeleton": "final\nclass\nEssentialsServiceProvider\nextends BaseServiceProvider\n{\nprivate array $configurables = [\n        Configurables\\AggressivePrefetching::class,\n        Configurables\\AutomaticallyEagerLoadRelationships::class,\n        Configurables\\FakeSleep::class,\n        Configurables\\ForceScheme::class,\n        Configurables\\ImmutableDates::class,\n        Configurables\\PreventStrayRequests::class,\n        Configurables\\ProhibitDestructiveCommands::class,\n        Configurables\\SetDefaultPassword::class,\n        Configurables\\ShouldBeStrict::class,\n        Configurables\\Unguard::class,\n    ];\nprivate array $commandsList = [\n        Commands\\EssentialsRectorCommand::class,\n        Commands\\EssentialsPintCommand::class,\n        Commands\\MakeActionCommand::class,\n    ];\npublic function boot () : void {}\n}", "code_description": "This code segment functions to: Register and configure application components during service initialization, including conditional registration of console commands and publication of configuration assets based on runtime environment."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```php\n[TASK_BEGIN]\n    public function boot(): void\n    {\n        foreach ($this->configurables as $configurable) {\n            $this->app->make($configurable)->configure();\n        }\n\n        $this->commands($this->commandsList);\n    }\n[TASK_END]\n```", "inference_time": "2025-08-20 21-14-22"}, "editdistance_info": {"edit_distance": 11.0145, "calculate_time": "2025-08-20 21:14:22", "true_code_clean": "final class EssentialsServiceProvider extends BaseServiceProvider\n{\n    private array $configurables = [\n        Configurables\\AggressivePrefetching::class,\n        Configurables\\AutomaticallyEagerLoadRelationships::class,\n        Configurables\\FakeSleep::class,\n        Configurables\\ForceScheme::class,\n        Configurables\\ImmutableDates::class,\n        Configurables\\PreventStrayRequests::class,\n        Configurables\\ProhibitDestructiveCommands::class,\n        Configurables\\SetDefaultPassword::class,\n        Configurables\\ShouldBeStrict::class,\n        Configurables\\Unguard::class,\n    ];\n    private array $commandsList = [\n        Commands\\EssentialsRectorCommand::class,\n        Commands\\EssentialsPintCommand::class,\n        Commands\\MakeActionCommand::class,\n    ];\n    public function boot(): void\n    {\n        collect($this->configurables)\n            ->map(fn (string $configurable) => $this->app->make($configurable))\n            ->filter(fn (Configurable $configurable): bool => $configurable->enabled())\n            ->each(fn (Configurable $configurable) => $configurable->configure());\n        if ($this->app->runningInConsole()) {\n            $this->commands($this->commandsList);\n            $this->publishes([\n                __DIR__.'/../stubs' => $this->app->basePath('stubs'),\n            ], 'essentials-stubs');\n            $this->publishes([\n                __DIR__.'/../config/essentials.php' => config_path('essentials.php'),\n            ]);\n        }\n    }\n}", "predict_code_clean": "public function boot(): void\n    {\n        foreach ($this->configurables as $configurable) {\n            $this->app->make($configurable)->configure();\n        }\n        $this->commands($this->commandsList);\n    }"}}
{"repo_name": "essentials", "file_name": "/essentials/src/Configurables/SetDefaultPassword.php", "inference_info": {"prefix_code": "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Validation\\Rules\\Password;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\n", "suffix_code": "\n", "middle_code": "final class SetDefaultPassword implements Configurable\n{\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n    public function configure(): void\n    {\n        Password::defaults(fn (): ?Password => app()->isProduction() ? Password::min(12)->max(255)->uncompromised() : null);\n    }\n}", "code_description": null, "fill_type": "CLASS_TYPE", "language_type": "php", "sub_task_type": null}, "context_code": [["/essentials/src/Configurables/ProhibitDestructiveCommands.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\DB;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ProhibitDestructiveCommands implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        DB::prohibitDestructiveCommands(\n            app()->isProduction(),\n        );\n    }\n}\n"], ["/essentials/src/EssentialsServiceProvider.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\ServiceProvider as BaseServiceProvider;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\n/**\n * @internal\n */\nfinal class EssentialsServiceProvider extends BaseServiceProvider\n{\n    /**\n     * The list of configurables.\n     *\n     * @var list<class-string<Configurable>>\n     */\n    private array $configurables = [\n        Configurables\\AggressivePrefetching::class,\n        Configurables\\AutomaticallyEagerLoadRelationships::class,\n        Configurables\\FakeSleep::class,\n        Configurables\\ForceScheme::class,\n        Configurables\\ImmutableDates::class,\n        Configurables\\PreventStrayRequests::class,\n        Configurables\\ProhibitDestructiveCommands::class,\n        Configurables\\SetDefaultPassword::class,\n        Configurables\\ShouldBeStrict::class,\n        Configurables\\Unguard::class,\n    ];\n\n    /**\n     * The list of commands.\n     *\n     * @var list<class-string<Command>>\n     */\n    private array $commandsList = [\n        Commands\\EssentialsRectorCommand::class,\n        Commands\\EssentialsPintCommand::class,\n        Commands\\MakeActionCommand::class,\n    ];\n\n    /**\n     * Bootstrap the application services.\n     */\n    public function boot(): void\n    {\n        collect($this->configurables)\n            ->map(fn (string $configurable) => $this->app->make($configurable))\n            ->filter(fn (Configurable $configurable): bool => $configurable->enabled())\n            ->each(fn (Configurable $configurable) => $configurable->configure());\n\n        if ($this->app->runningInConsole()) {\n            $this->commands($this->commandsList);\n\n            $this->publishes([\n                __DIR__.'/../stubs' => $this->app->basePath('stubs'),\n            ], 'essentials-stubs');\n\n            $this->publishes([\n                __DIR__.'/../config/essentials.php' => config_path('essentials.php'),\n            ]);\n        }\n    }\n}\n"], ["/essentials/src/Configurables/ImmutableDates.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Support\\Facades\\Date;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ImmutableDates implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Date::use(CarbonImmutable::class);\n    }\n}\n"], ["/essentials/src/Configurables/ForceScheme.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\URL;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ForceScheme implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        URL::forceHttps();\n    }\n}\n"], ["/essentials/src/Configurables/FakeSleep.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Sleep;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class FakeSleep implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        $enabled = config()->boolean(sprintf('essentials.%s', self::class), true);\n        $testing = app()->runningUnitTests();\n\n        return $enabled && $testing;\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Sleep::fake();\n    }\n}\n"], ["/essentials/src/Configurables/PreventStrayRequests.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\Http;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class PreventStrayRequests implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        $enabled = config()->boolean(sprintf('essentials.%s', self::class), true);\n        $testing = app()->runningUnitTests();\n\n        return $enabled && $testing;\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Http::preventStrayRequests();\n    }\n}\n"], ["/essentials/src/Configurables/ShouldBeStrict.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ShouldBeStrict implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Model::shouldBeStrict();\n    }\n}\n"], ["/essentials/src/Configurables/Unguard.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class Unguard implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), false);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Model::unguard();\n    }\n}\n"], ["/essentials/src/Configurables/AggressivePrefetching.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\Vite;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class AggressivePrefetching implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Vite::useAggressivePrefetching();\n    }\n}\n"], ["/essentials/src/Configurables/AutomaticallyEagerLoadRelationships.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class AutomaticallyEagerLoadRelationships implements Configurable\n{\n    public function __construct(\n        private string $modelClass = Model::class\n    ) {}\n\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        if (! method_exists($this->modelClass, 'automaticallyEagerLoadRelationships')) {\n            return;\n        }\n\n        Model::automaticallyEagerLoadRelationships();\n    }\n}\n"], ["/essentials/src/Commands/MakeActionCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\GeneratorCommand;\nuse Illuminate\\Support\\Str;\n\nfinal class MakeActionCommand extends GeneratorCommand\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $name = 'make:action';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'Create a new action class';\n\n    /**\n     * The type of class being generated.\n     *\n     * @var string\n     */\n    protected $type = 'Action';\n\n    /**\n     * Execute the console command.\n     *\n     * @return bool|int|null\n     */\n    public function handle()\n    {\n        // First check if the class already exists\n        if ($this->alreadyExists($this->getNameInput())) {\n            $this->error($this->type.' already exists!');\n\n            return 1;\n        }\n\n        return parent::handle();\n    }\n\n    /**\n     * Get the name input.\n     */\n    protected function getNameInput(): string\n    {\n        /** @var string $name */\n        $name = $this->argument('name');\n\n        return Str::of(mb_trim($name))\n            ->replaceEnd('.php', '')\n            ->replaceEnd('Action', '')\n            ->append('Action')\n            ->toString();\n    }\n\n    /**\n     * Get the stub file for the generator.\n     */\n    protected function getStub(): string\n    {\n        return $this->resolveStubPath('/stubs/action.stub');\n    }\n\n    /**\n     * Get the default namespace for the class.\n     */\n    protected function getDefaultNamespace($rootNamespace): string\n    {\n        return $rootNamespace.'\\Actions';\n    }\n\n    /**\n     * Get the destination class path.\n     */\n    protected function getPath($name): string\n    {\n        $name = Str::replaceFirst($this->rootNamespace(), '', $name);\n\n        // Use the app_path helper to get the correct path\n        return app_path(str_replace('\\\\', '/', $name).'.php');\n    }\n\n    /**\n     * Resolve the fully-qualified path to the stub.\n     */\n    private function resolveStubPath(string $stub): string\n    {\n        $basePath = $this->laravel->basePath(mb_trim($stub, '/'));\n\n        return file_exists($basePath)\n            ? $basePath\n            : __DIR__.'/../../'.$stub;\n    }\n}\n"], ["/essentials/src/Contracts/Configurable.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Contracts;\n\n/**\n * @internal\n */\ninterface Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool;\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void;\n}\n"], ["/essentials/src/Commands/EssentialsPintCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Facades\\File;\n\nfinal class EssentialsPintCommand extends Command\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $signature = 'essentials:pint\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing pint.json}';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'This command will publish an opinionated Pint configuration file for your project.';\n\n    /**\n     * Execute the console command.\n     */\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Pint configuration file? This will override the existing [pint.json] file.', true)) {\n            return 0;\n        }\n\n        $stub_path = __DIR__.'/../../stubs/pint.stub';\n        $destination_path = base_path('pint.json');\n\n        if (! File::exists($stub_path)) {\n            $this->components->error('Pint configuration stub file not found.');\n\n            return 1;\n        }\n\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n\n        $this->components->info('Publishing Pint configuration file...');\n\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Pint configuration file.');\n\n            return 1;\n        }\n\n        $this->components->info('Pint configuration file published successfully at: '.$destination_path);\n\n        return 0;\n    }\n}\n"], ["/essentials/src/Commands/EssentialsRectorCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Facades\\File;\n\nfinal class EssentialsRectorCommand extends Command\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $signature = 'essentials:rector\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing rector.php}';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'This command will publish an opinionated Rector configuration file for your project.';\n\n    /**\n     * Execute the console command.\n     */\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Rector configuration file? This will override the existing [rector.php] file.', true)) {\n            return 0;\n        }\n\n        $stub_path = __DIR__.'/../../stubs/rector.stub';\n        $destination_path = base_path('rector.php');\n\n        if (! File::exists($stub_path)) {\n            $this->components->error('Rector configuration stub file not found.');\n\n            return 1;\n        }\n\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n\n        $this->components->info('Publishing Rector configuration file...');\n\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Rector configuration file.');\n\n            return 1;\n        }\n\n        $this->components->info('Rector configuration file published successfully at: '.$destination_path);\n\n        return 0;\n    }\n}\n"], ["/essentials/rector.php", "<?php\n\ndeclare(strict_types=1);\n\nuse Rector\\Config\\RectorConfig;\nuse Rector\\Php83\\Rector\\ClassMethod\\AddOverrideAttributeToOverriddenMethodsRector;\n\nreturn RectorConfig::configure()\n    ->withPaths([\n        __DIR__.'/src',\n        __DIR__.'/tests',\n    ])\n    ->withSkip([\n        AddOverrideAttributeToOverriddenMethodsRector::class,\n    ])\n    ->withPreparedSets(\n        deadCode: true,\n        codeQuality: true,\n        typeDeclarations: true,\n        privatization: true,\n        earlyReturn: true,\n        strictBooleans: true,\n    )\n    ->withPhpSets();\n"]], "task_instance_info": {"created_time": "2025-08-20 21:14:06", "created_task_model": "DeepSeek-R1", "class_skeleton": "final\nclass\nSetDefaultPassword\nimplements Configurable\n{\npublic function enabled () : bool {}\npublic function configure () : void {}\n}", "code_description": "This code segment functions to: Define environment-specific password policy configurations and dynamically adjust complexity requirements based on application runtime conditions."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```php\n[TASK_BEGIN]\nfinal class SetDefaultPassword implements Configurable\n{\n    public function enabled(): bool\n    {\n        return true;\n    }\n\n    public function configure(): void\n    {\n        Password::defaults(function () {\n            return Password::min(8)\n                ->letters()\n                ->numbers()\n                ->symbols()\n                ->mixedCase();\n        });\n    }\n}\n[TASK_END]\n```", "inference_time": "2025-08-20 21-14-26"}, "editdistance_info": {"edit_distance": 45.977, "calculate_time": "2025-08-20 21:14:26", "true_code_clean": "final class SetDefaultPassword implements Configurable\n{\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n    public function configure(): void\n    {\n        Password::defaults(fn (): ?Password => app()->isProduction() ? Password::min(12)->max(255)->uncompromised() : null);\n    }\n}", "predict_code_clean": "final class SetDefaultPassword implements Configurable\n{\n    public function enabled(): bool\n    {\n        return true;\n    }\n    public function configure(): void\n    {\n        Password::defaults(function () {\n            return Password::min(8)\n                ->letters()\n                ->numbers()\n                ->symbols()\n                ->mixedCase();\n        });\n    }\n}"}}
{"repo_name": "essentials", "file_name": "/essentials/src/Commands/EssentialsPintCommand.php", "inference_info": {"prefix_code": "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Facades\\File;\n\n", "suffix_code": "\n", "middle_code": "final class EssentialsPintCommand extends Command\n{\n    protected $signature = 'essentials:pint\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing pint.json}';\n    protected $description = 'This command will publish an opinionated Pint configuration file for your project.';\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Pint configuration file? This will override the existing [pint.json] file.', true)) {\n            return 0;\n        }\n        $stub_path = __DIR__.'/../../stubs/pint.stub';\n        $destination_path = base_path('pint.json');\n        if (! File::exists($stub_path)) {\n            $this->components->error('Pint configuration stub file not found.');\n            return 1;\n        }\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n        $this->components->info('Publishing Pint configuration file...');\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Pint configuration file.');\n            return 1;\n        }\n        $this->components->info('Pint configuration file published successfully at: '.$destination_path);\n        return 0;\n    }\n}", "code_description": null, "fill_type": "CLASS_TYPE", "language_type": "php", "sub_task_type": null}, "context_code": [["/essentials/src/Commands/EssentialsRectorCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Facades\\File;\n\nfinal class EssentialsRectorCommand extends Command\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $signature = 'essentials:rector\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing rector.php}';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'This command will publish an opinionated Rector configuration file for your project.';\n\n    /**\n     * Execute the console command.\n     */\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Rector configuration file? This will override the existing [rector.php] file.', true)) {\n            return 0;\n        }\n\n        $stub_path = __DIR__.'/../../stubs/rector.stub';\n        $destination_path = base_path('rector.php');\n\n        if (! File::exists($stub_path)) {\n            $this->components->error('Rector configuration stub file not found.');\n\n            return 1;\n        }\n\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n\n        $this->components->info('Publishing Rector configuration file...');\n\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Rector configuration file.');\n\n            return 1;\n        }\n\n        $this->components->info('Rector configuration file published successfully at: '.$destination_path);\n\n        return 0;\n    }\n}\n"], ["/essentials/src/Commands/MakeActionCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\GeneratorCommand;\nuse Illuminate\\Support\\Str;\n\nfinal class MakeActionCommand extends GeneratorCommand\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $name = 'make:action';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'Create a new action class';\n\n    /**\n     * The type of class being generated.\n     *\n     * @var string\n     */\n    protected $type = 'Action';\n\n    /**\n     * Execute the console command.\n     *\n     * @return bool|int|null\n     */\n    public function handle()\n    {\n        // First check if the class already exists\n        if ($this->alreadyExists($this->getNameInput())) {\n            $this->error($this->type.' already exists!');\n\n            return 1;\n        }\n\n        return parent::handle();\n    }\n\n    /**\n     * Get the name input.\n     */\n    protected function getNameInput(): string\n    {\n        /** @var string $name */\n        $name = $this->argument('name');\n\n        return Str::of(mb_trim($name))\n            ->replaceEnd('.php', '')\n            ->replaceEnd('Action', '')\n            ->append('Action')\n            ->toString();\n    }\n\n    /**\n     * Get the stub file for the generator.\n     */\n    protected function getStub(): string\n    {\n        return $this->resolveStubPath('/stubs/action.stub');\n    }\n\n    /**\n     * Get the default namespace for the class.\n     */\n    protected function getDefaultNamespace($rootNamespace): string\n    {\n        return $rootNamespace.'\\Actions';\n    }\n\n    /**\n     * Get the destination class path.\n     */\n    protected function getPath($name): string\n    {\n        $name = Str::replaceFirst($this->rootNamespace(), '', $name);\n\n        // Use the app_path helper to get the correct path\n        return app_path(str_replace('\\\\', '/', $name).'.php');\n    }\n\n    /**\n     * Resolve the fully-qualified path to the stub.\n     */\n    private function resolveStubPath(string $stub): string\n    {\n        $basePath = $this->laravel->basePath(mb_trim($stub, '/'));\n\n        return file_exists($basePath)\n            ? $basePath\n            : __DIR__.'/../../'.$stub;\n    }\n}\n"], ["/essentials/src/EssentialsServiceProvider.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\ServiceProvider as BaseServiceProvider;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\n/**\n * @internal\n */\nfinal class EssentialsServiceProvider extends BaseServiceProvider\n{\n    /**\n     * The list of configurables.\n     *\n     * @var list<class-string<Configurable>>\n     */\n    private array $configurables = [\n        Configurables\\AggressivePrefetching::class,\n        Configurables\\AutomaticallyEagerLoadRelationships::class,\n        Configurables\\FakeSleep::class,\n        Configurables\\ForceScheme::class,\n        Configurables\\ImmutableDates::class,\n        Configurables\\PreventStrayRequests::class,\n        Configurables\\ProhibitDestructiveCommands::class,\n        Configurables\\SetDefaultPassword::class,\n        Configurables\\ShouldBeStrict::class,\n        Configurables\\Unguard::class,\n    ];\n\n    /**\n     * The list of commands.\n     *\n     * @var list<class-string<Command>>\n     */\n    private array $commandsList = [\n        Commands\\EssentialsRectorCommand::class,\n        Commands\\EssentialsPintCommand::class,\n        Commands\\MakeActionCommand::class,\n    ];\n\n    /**\n     * Bootstrap the application services.\n     */\n    public function boot(): void\n    {\n        collect($this->configurables)\n            ->map(fn (string $configurable) => $this->app->make($configurable))\n            ->filter(fn (Configurable $configurable): bool => $configurable->enabled())\n            ->each(fn (Configurable $configurable) => $configurable->configure());\n\n        if ($this->app->runningInConsole()) {\n            $this->commands($this->commandsList);\n\n            $this->publishes([\n                __DIR__.'/../stubs' => $this->app->basePath('stubs'),\n            ], 'essentials-stubs');\n\n            $this->publishes([\n                __DIR__.'/../config/essentials.php' => config_path('essentials.php'),\n            ]);\n        }\n    }\n}\n"], ["/essentials/src/Configurables/AutomaticallyEagerLoadRelationships.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class AutomaticallyEagerLoadRelationships implements Configurable\n{\n    public function __construct(\n        private string $modelClass = Model::class\n    ) {}\n\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        if (! method_exists($this->modelClass, 'automaticallyEagerLoadRelationships')) {\n            return;\n        }\n\n        Model::automaticallyEagerLoadRelationships();\n    }\n}\n"], ["/essentials/src/Configurables/PreventStrayRequests.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\Http;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class PreventStrayRequests implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        $enabled = config()->boolean(sprintf('essentials.%s', self::class), true);\n        $testing = app()->runningUnitTests();\n\n        return $enabled && $testing;\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Http::preventStrayRequests();\n    }\n}\n"], ["/essentials/src/Configurables/FakeSleep.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Sleep;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class FakeSleep implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        $enabled = config()->boolean(sprintf('essentials.%s', self::class), true);\n        $testing = app()->runningUnitTests();\n\n        return $enabled && $testing;\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Sleep::fake();\n    }\n}\n"], ["/essentials/src/Configurables/ProhibitDestructiveCommands.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\DB;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ProhibitDestructiveCommands implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        DB::prohibitDestructiveCommands(\n            app()->isProduction(),\n        );\n    }\n}\n"], ["/essentials/src/Configurables/ForceScheme.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\URL;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ForceScheme implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        URL::forceHttps();\n    }\n}\n"], ["/essentials/src/Configurables/AggressivePrefetching.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\Vite;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class AggressivePrefetching implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Vite::useAggressivePrefetching();\n    }\n}\n"], ["/essentials/src/Configurables/ImmutableDates.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Support\\Facades\\Date;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ImmutableDates implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Date::use(CarbonImmutable::class);\n    }\n}\n"], ["/essentials/src/Configurables/SetDefaultPassword.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Validation\\Rules\\Password;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal class SetDefaultPassword implements Configurable\n{\n    /**\n     * {@inheritDoc}\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    public function configure(): void\n    {\n        Password::defaults(fn (): ?Password => app()->isProduction() ? Password::min(12)->max(255)->uncompromised() : null);\n    }\n}\n"], ["/essentials/rector.php", "<?php\n\ndeclare(strict_types=1);\n\nuse Rector\\Config\\RectorConfig;\nuse Rector\\Php83\\Rector\\ClassMethod\\AddOverrideAttributeToOverriddenMethodsRector;\n\nreturn RectorConfig::configure()\n    ->withPaths([\n        __DIR__.'/src',\n        __DIR__.'/tests',\n    ])\n    ->withSkip([\n        AddOverrideAttributeToOverriddenMethodsRector::class,\n    ])\n    ->withPreparedSets(\n        deadCode: true,\n        codeQuality: true,\n        typeDeclarations: true,\n        privatization: true,\n        earlyReturn: true,\n        strictBooleans: true,\n    )\n    ->withPhpSets();\n"], ["/essentials/src/Configurables/ShouldBeStrict.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ShouldBeStrict implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Model::shouldBeStrict();\n    }\n}\n"], ["/essentials/src/Configurables/Unguard.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class Unguard implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), false);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Model::unguard();\n    }\n}\n"], ["/essentials/src/Contracts/Configurable.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Contracts;\n\n/**\n * @internal\n */\ninterface Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool;\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void;\n}\n"]], "task_instance_info": {"created_time": "2025-08-20 21:14:06", "created_task_model": "DeepSeek-R1", "class_skeleton": "final\nclass\nEssentialsPintCommand\nextends Command\n{\nprotected $signature = 'essentials:pint\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing pint.json}';\nprotected $description = 'This command will publish an opinionated Pint configuration file for your project.';\npublic function handle () : int {}\n}", "code_description": "This code segment functions to: Handle user confirmation and optional backup operations before deploying a predefined configuration template to a target location, while providing success/failure feedback throughout the process."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```php\n[TASK_BEGIN]\npublic function handle(): int\n{\n    $destination = base_path('pint.json');\n\n    if (File::exists($destination) && !$this->option('force')) {\n        if (!$this->confirm('pint.json already exists. Overwrite?')) {\n            return self::FAILURE;\n        }\n    }\n\n    if ($this->option('backup') && File::exists($destination)) {\n        $backupPath = $destination . '.backup.' . time();\n        File::copy($destination, $backupPath);\n        $this->info('Created backup: ' . basename($backupPath));\n    }\n\n    File::copy(__DIR__ . '/../stubs/pint.json', $destination);\n    $this->info('Successfully published opinionated Pint configuration!');\n\n    return self::SUCCESS;\n}\n[TASK_END]\n```", "inference_time": "2025-08-20 21-14-27"}, "editdistance_info": {"edit_distance": 17.5385, "calculate_time": "2025-08-20 21:14:27", "true_code_clean": "final class EssentialsPintCommand extends Command\n{\n    protected $signature = 'essentials:pint\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing pint.json}';\n    protected $description = 'This command will publish an opinionated Pint configuration file for your project.';\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Pint configuration file? This will override the existing [pint.json] file.', true)) {\n            return 0;\n        }\n        $stub_path = __DIR__.'/../../stubs/pint.stub';\n        $destination_path = base_path('pint.json');\n        if (! File::exists($stub_path)) {\n            $this->components->error('Pint configuration stub file not found.');\n            return 1;\n        }\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n        $this->components->info('Publishing Pint configuration file...');\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Pint configuration file.');\n            return 1;\n        }\n        $this->components->info('Pint configuration file published successfully at: '.$destination_path);\n        return 0;\n    }\n}", "predict_code_clean": "public function handle(): int\n{\n    $destination = base_path('pint.json');\n    if (File::exists($destination) && !$this->option('force')) {\n        if (!$this->confirm('pint.json already exists. Overwrite?')) {\n            return self::FAILURE;\n        }\n    }\n    if ($this->option('backup') && File::exists($destination)) {\n        $backupPath = $destination . '.backup.' . time();\n        File::copy($destination, $backupPath);\n        $this->info('Created backup: ' . basename($backupPath));\n    }\n    File::copy(__DIR__ . '/../stubs/pint.json', $destination);\n    $this->info('Successfully published opinionated Pint configuration!');\n    return self::SUCCESS;\n}"}}
{"repo_name": "essentials", "file_name": "/essentials/src/Configurables/ImmutableDates.php", "inference_info": {"prefix_code": "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Support\\Facades\\Date;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\n", "suffix_code": "\n", "middle_code": "final readonly class ImmutableDates implements Configurable\n{\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n    public function configure(): void\n    {\n        Date::use(CarbonImmutable::class);\n    }\n}", "code_description": null, "fill_type": "CLASS_TYPE", "language_type": "php", "sub_task_type": null}, "context_code": [["/essentials/src/Configurables/ForceScheme.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\URL;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ForceScheme implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        URL::forceHttps();\n    }\n}\n"], ["/essentials/src/Configurables/AggressivePrefetching.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\Vite;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class AggressivePrefetching implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Vite::useAggressivePrefetching();\n    }\n}\n"], ["/essentials/src/Configurables/ProhibitDestructiveCommands.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\DB;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ProhibitDestructiveCommands implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        DB::prohibitDestructiveCommands(\n            app()->isProduction(),\n        );\n    }\n}\n"], ["/essentials/src/Configurables/PreventStrayRequests.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\Http;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class PreventStrayRequests implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        $enabled = config()->boolean(sprintf('essentials.%s', self::class), true);\n        $testing = app()->runningUnitTests();\n\n        return $enabled && $testing;\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Http::preventStrayRequests();\n    }\n}\n"], ["/essentials/src/Configurables/ShouldBeStrict.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ShouldBeStrict implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Model::shouldBeStrict();\n    }\n}\n"], ["/essentials/src/Configurables/FakeSleep.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Sleep;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class FakeSleep implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        $enabled = config()->boolean(sprintf('essentials.%s', self::class), true);\n        $testing = app()->runningUnitTests();\n\n        return $enabled && $testing;\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Sleep::fake();\n    }\n}\n"], ["/essentials/src/Configurables/SetDefaultPassword.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Validation\\Rules\\Password;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal class SetDefaultPassword implements Configurable\n{\n    /**\n     * {@inheritDoc}\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    public function configure(): void\n    {\n        Password::defaults(fn (): ?Password => app()->isProduction() ? Password::min(12)->max(255)->uncompromised() : null);\n    }\n}\n"], ["/essentials/src/Configurables/Unguard.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class Unguard implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), false);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Model::unguard();\n    }\n}\n"], ["/essentials/src/Configurables/AutomaticallyEagerLoadRelationships.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class AutomaticallyEagerLoadRelationships implements Configurable\n{\n    public function __construct(\n        private string $modelClass = Model::class\n    ) {}\n\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        if (! method_exists($this->modelClass, 'automaticallyEagerLoadRelationships')) {\n            return;\n        }\n\n        Model::automaticallyEagerLoadRelationships();\n    }\n}\n"], ["/essentials/src/EssentialsServiceProvider.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\ServiceProvider as BaseServiceProvider;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\n/**\n * @internal\n */\nfinal class EssentialsServiceProvider extends BaseServiceProvider\n{\n    /**\n     * The list of configurables.\n     *\n     * @var list<class-string<Configurable>>\n     */\n    private array $configurables = [\n        Configurables\\AggressivePrefetching::class,\n        Configurables\\AutomaticallyEagerLoadRelationships::class,\n        Configurables\\FakeSleep::class,\n        Configurables\\ForceScheme::class,\n        Configurables\\ImmutableDates::class,\n        Configurables\\PreventStrayRequests::class,\n        Configurables\\ProhibitDestructiveCommands::class,\n        Configurables\\SetDefaultPassword::class,\n        Configurables\\ShouldBeStrict::class,\n        Configurables\\Unguard::class,\n    ];\n\n    /**\n     * The list of commands.\n     *\n     * @var list<class-string<Command>>\n     */\n    private array $commandsList = [\n        Commands\\EssentialsRectorCommand::class,\n        Commands\\EssentialsPintCommand::class,\n        Commands\\MakeActionCommand::class,\n    ];\n\n    /**\n     * Bootstrap the application services.\n     */\n    public function boot(): void\n    {\n        collect($this->configurables)\n            ->map(fn (string $configurable) => $this->app->make($configurable))\n            ->filter(fn (Configurable $configurable): bool => $configurable->enabled())\n            ->each(fn (Configurable $configurable) => $configurable->configure());\n\n        if ($this->app->runningInConsole()) {\n            $this->commands($this->commandsList);\n\n            $this->publishes([\n                __DIR__.'/../stubs' => $this->app->basePath('stubs'),\n            ], 'essentials-stubs');\n\n            $this->publishes([\n                __DIR__.'/../config/essentials.php' => config_path('essentials.php'),\n            ]);\n        }\n    }\n}\n"], ["/essentials/src/Contracts/Configurable.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Contracts;\n\n/**\n * @internal\n */\ninterface Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool;\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void;\n}\n"], ["/essentials/src/Commands/MakeActionCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\GeneratorCommand;\nuse Illuminate\\Support\\Str;\n\nfinal class MakeActionCommand extends GeneratorCommand\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $name = 'make:action';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'Create a new action class';\n\n    /**\n     * The type of class being generated.\n     *\n     * @var string\n     */\n    protected $type = 'Action';\n\n    /**\n     * Execute the console command.\n     *\n     * @return bool|int|null\n     */\n    public function handle()\n    {\n        // First check if the class already exists\n        if ($this->alreadyExists($this->getNameInput())) {\n            $this->error($this->type.' already exists!');\n\n            return 1;\n        }\n\n        return parent::handle();\n    }\n\n    /**\n     * Get the name input.\n     */\n    protected function getNameInput(): string\n    {\n        /** @var string $name */\n        $name = $this->argument('name');\n\n        return Str::of(mb_trim($name))\n            ->replaceEnd('.php', '')\n            ->replaceEnd('Action', '')\n            ->append('Action')\n            ->toString();\n    }\n\n    /**\n     * Get the stub file for the generator.\n     */\n    protected function getStub(): string\n    {\n        return $this->resolveStubPath('/stubs/action.stub');\n    }\n\n    /**\n     * Get the default namespace for the class.\n     */\n    protected function getDefaultNamespace($rootNamespace): string\n    {\n        return $rootNamespace.'\\Actions';\n    }\n\n    /**\n     * Get the destination class path.\n     */\n    protected function getPath($name): string\n    {\n        $name = Str::replaceFirst($this->rootNamespace(), '', $name);\n\n        // Use the app_path helper to get the correct path\n        return app_path(str_replace('\\\\', '/', $name).'.php');\n    }\n\n    /**\n     * Resolve the fully-qualified path to the stub.\n     */\n    private function resolveStubPath(string $stub): string\n    {\n        $basePath = $this->laravel->basePath(mb_trim($stub, '/'));\n\n        return file_exists($basePath)\n            ? $basePath\n            : __DIR__.'/../../'.$stub;\n    }\n}\n"], ["/essentials/src/Commands/EssentialsPintCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Facades\\File;\n\nfinal class EssentialsPintCommand extends Command\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $signature = 'essentials:pint\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing pint.json}';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'This command will publish an opinionated Pint configuration file for your project.';\n\n    /**\n     * Execute the console command.\n     */\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Pint configuration file? This will override the existing [pint.json] file.', true)) {\n            return 0;\n        }\n\n        $stub_path = __DIR__.'/../../stubs/pint.stub';\n        $destination_path = base_path('pint.json');\n\n        if (! File::exists($stub_path)) {\n            $this->components->error('Pint configuration stub file not found.');\n\n            return 1;\n        }\n\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n\n        $this->components->info('Publishing Pint configuration file...');\n\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Pint configuration file.');\n\n            return 1;\n        }\n\n        $this->components->info('Pint configuration file published successfully at: '.$destination_path);\n\n        return 0;\n    }\n}\n"], ["/essentials/src/Commands/EssentialsRectorCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Facades\\File;\n\nfinal class EssentialsRectorCommand extends Command\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $signature = 'essentials:rector\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing rector.php}';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'This command will publish an opinionated Rector configuration file for your project.';\n\n    /**\n     * Execute the console command.\n     */\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Rector configuration file? This will override the existing [rector.php] file.', true)) {\n            return 0;\n        }\n\n        $stub_path = __DIR__.'/../../stubs/rector.stub';\n        $destination_path = base_path('rector.php');\n\n        if (! File::exists($stub_path)) {\n            $this->components->error('Rector configuration stub file not found.');\n\n            return 1;\n        }\n\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n\n        $this->components->info('Publishing Rector configuration file...');\n\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Rector configuration file.');\n\n            return 1;\n        }\n\n        $this->components->info('Rector configuration file published successfully at: '.$destination_path);\n\n        return 0;\n    }\n}\n"], ["/essentials/rector.php", "<?php\n\ndeclare(strict_types=1);\n\nuse Rector\\Config\\RectorConfig;\nuse Rector\\Php83\\Rector\\ClassMethod\\AddOverrideAttributeToOverriddenMethodsRector;\n\nreturn RectorConfig::configure()\n    ->withPaths([\n        __DIR__.'/src',\n        __DIR__.'/tests',\n    ])\n    ->withSkip([\n        AddOverrideAttributeToOverriddenMethodsRector::class,\n    ])\n    ->withPreparedSets(\n        deadCode: true,\n        codeQuality: true,\n        typeDeclarations: true,\n        privatization: true,\n        earlyReturn: true,\n        strictBooleans: true,\n    )\n    ->withPhpSets();\n"]], "task_instance_info": {"created_time": "2025-08-20 21:14:06", "created_task_model": "DeepSeek-R1", "class_skeleton": "final\nreadonly\nclass\nImmutableDates\nimplements Configurable\n{\npublic function enabled () : bool {}\npublic function configure () : void {}\n}", "code_description": "This code segment functions to: Configure runtime dependencies to utilize immutable time representations and conditionally enable this modification based on application settings."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```php\n[TASK_BEGIN]\nfinal readonly class ImmutableDates implements Configurable\n{\n    public function enabled(): bool\n    {\n        return true;\n    }\n\n    public function configure(): void\n    {\n        Date::use(function ($date) {\n            return $date ? CarbonImmutable::parse($date) : new CarbonImmutable();\n        });\n    }\n}\n[TASK_END]\n```", "inference_time": "2025-08-20 21-14-29"}, "editdistance_info": {"edit_distance": 43.0769, "calculate_time": "2025-08-20 21:14:29", "true_code_clean": "final readonly class ImmutableDates implements Configurable\n{\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n    public function configure(): void\n    {\n        Date::use(CarbonImmutable::class);\n    }\n}", "predict_code_clean": "final readonly class ImmutableDates implements Configurable\n{\n    public function enabled(): bool\n    {\n        return true;\n    }\n    public function configure(): void\n    {\n        Date::use(function ($date) {\n            return $date ? CarbonImmutable::parse($date) : new CarbonImmutable();\n        });\n    }\n}"}}
{"repo_name": "essentials", "file_name": "/essentials/src/Configurables/ProhibitDestructiveCommands.php", "inference_info": {"prefix_code": "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\DB;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\n", "suffix_code": "\n", "middle_code": "final readonly class ProhibitDestructiveCommands implements Configurable\n{\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n    public function configure(): void\n    {\n        DB::prohibitDestructiveCommands(\n            app()->isProduction(),\n        );\n    }\n}", "code_description": null, "fill_type": "CLASS_TYPE", "language_type": "php", "sub_task_type": null}, "context_code": [["/essentials/src/Configurables/SetDefaultPassword.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Validation\\Rules\\Password;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal class SetDefaultPassword implements Configurable\n{\n    /**\n     * {@inheritDoc}\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * {@inheritDoc}\n     */\n    public function configure(): void\n    {\n        Password::defaults(fn (): ?Password => app()->isProduction() ? Password::min(12)->max(255)->uncompromised() : null);\n    }\n}\n"], ["/essentials/src/EssentialsServiceProvider.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\ServiceProvider as BaseServiceProvider;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\n/**\n * @internal\n */\nfinal class EssentialsServiceProvider extends BaseServiceProvider\n{\n    /**\n     * The list of configurables.\n     *\n     * @var list<class-string<Configurable>>\n     */\n    private array $configurables = [\n        Configurables\\AggressivePrefetching::class,\n        Configurables\\AutomaticallyEagerLoadRelationships::class,\n        Configurables\\FakeSleep::class,\n        Configurables\\ForceScheme::class,\n        Configurables\\ImmutableDates::class,\n        Configurables\\PreventStrayRequests::class,\n        Configurables\\ProhibitDestructiveCommands::class,\n        Configurables\\SetDefaultPassword::class,\n        Configurables\\ShouldBeStrict::class,\n        Configurables\\Unguard::class,\n    ];\n\n    /**\n     * The list of commands.\n     *\n     * @var list<class-string<Command>>\n     */\n    private array $commandsList = [\n        Commands\\EssentialsRectorCommand::class,\n        Commands\\EssentialsPintCommand::class,\n        Commands\\MakeActionCommand::class,\n    ];\n\n    /**\n     * Bootstrap the application services.\n     */\n    public function boot(): void\n    {\n        collect($this->configurables)\n            ->map(fn (string $configurable) => $this->app->make($configurable))\n            ->filter(fn (Configurable $configurable): bool => $configurable->enabled())\n            ->each(fn (Configurable $configurable) => $configurable->configure());\n\n        if ($this->app->runningInConsole()) {\n            $this->commands($this->commandsList);\n\n            $this->publishes([\n                __DIR__.'/../stubs' => $this->app->basePath('stubs'),\n            ], 'essentials-stubs');\n\n            $this->publishes([\n                __DIR__.'/../config/essentials.php' => config_path('essentials.php'),\n            ]);\n        }\n    }\n}\n"], ["/essentials/src/Configurables/PreventStrayRequests.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\Http;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class PreventStrayRequests implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        $enabled = config()->boolean(sprintf('essentials.%s', self::class), true);\n        $testing = app()->runningUnitTests();\n\n        return $enabled && $testing;\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Http::preventStrayRequests();\n    }\n}\n"], ["/essentials/src/Configurables/ForceScheme.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\URL;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ForceScheme implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        URL::forceHttps();\n    }\n}\n"], ["/essentials/src/Configurables/ImmutableDates.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Carbon\\CarbonImmutable;\nuse Illuminate\\Support\\Facades\\Date;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ImmutableDates implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Date::use(CarbonImmutable::class);\n    }\n}\n"], ["/essentials/src/Configurables/FakeSleep.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Sleep;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class FakeSleep implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        $enabled = config()->boolean(sprintf('essentials.%s', self::class), true);\n        $testing = app()->runningUnitTests();\n\n        return $enabled && $testing;\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Sleep::fake();\n    }\n}\n"], ["/essentials/src/Configurables/AutomaticallyEagerLoadRelationships.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class AutomaticallyEagerLoadRelationships implements Configurable\n{\n    public function __construct(\n        private string $modelClass = Model::class\n    ) {}\n\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        if (! method_exists($this->modelClass, 'automaticallyEagerLoadRelationships')) {\n            return;\n        }\n\n        Model::automaticallyEagerLoadRelationships();\n    }\n}\n"], ["/essentials/src/Configurables/AggressivePrefetching.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Support\\Facades\\Vite;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class AggressivePrefetching implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Vite::useAggressivePrefetching();\n    }\n}\n"], ["/essentials/src/Configurables/ShouldBeStrict.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class ShouldBeStrict implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Model::shouldBeStrict();\n    }\n}\n"], ["/essentials/src/Configurables/Unguard.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Configurables;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse NunoMaduro\\Essentials\\Contracts\\Configurable;\n\nfinal readonly class Unguard implements Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), false);\n    }\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void\n    {\n        Model::unguard();\n    }\n}\n"], ["/essentials/src/Commands/MakeActionCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\GeneratorCommand;\nuse Illuminate\\Support\\Str;\n\nfinal class MakeActionCommand extends GeneratorCommand\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $name = 'make:action';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'Create a new action class';\n\n    /**\n     * The type of class being generated.\n     *\n     * @var string\n     */\n    protected $type = 'Action';\n\n    /**\n     * Execute the console command.\n     *\n     * @return bool|int|null\n     */\n    public function handle()\n    {\n        // First check if the class already exists\n        if ($this->alreadyExists($this->getNameInput())) {\n            $this->error($this->type.' already exists!');\n\n            return 1;\n        }\n\n        return parent::handle();\n    }\n\n    /**\n     * Get the name input.\n     */\n    protected function getNameInput(): string\n    {\n        /** @var string $name */\n        $name = $this->argument('name');\n\n        return Str::of(mb_trim($name))\n            ->replaceEnd('.php', '')\n            ->replaceEnd('Action', '')\n            ->append('Action')\n            ->toString();\n    }\n\n    /**\n     * Get the stub file for the generator.\n     */\n    protected function getStub(): string\n    {\n        return $this->resolveStubPath('/stubs/action.stub');\n    }\n\n    /**\n     * Get the default namespace for the class.\n     */\n    protected function getDefaultNamespace($rootNamespace): string\n    {\n        return $rootNamespace.'\\Actions';\n    }\n\n    /**\n     * Get the destination class path.\n     */\n    protected function getPath($name): string\n    {\n        $name = Str::replaceFirst($this->rootNamespace(), '', $name);\n\n        // Use the app_path helper to get the correct path\n        return app_path(str_replace('\\\\', '/', $name).'.php');\n    }\n\n    /**\n     * Resolve the fully-qualified path to the stub.\n     */\n    private function resolveStubPath(string $stub): string\n    {\n        $basePath = $this->laravel->basePath(mb_trim($stub, '/'));\n\n        return file_exists($basePath)\n            ? $basePath\n            : __DIR__.'/../../'.$stub;\n    }\n}\n"], ["/essentials/src/Commands/EssentialsPintCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Facades\\File;\n\nfinal class EssentialsPintCommand extends Command\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $signature = 'essentials:pint\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing pint.json}';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'This command will publish an opinionated Pint configuration file for your project.';\n\n    /**\n     * Execute the console command.\n     */\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Pint configuration file? This will override the existing [pint.json] file.', true)) {\n            return 0;\n        }\n\n        $stub_path = __DIR__.'/../../stubs/pint.stub';\n        $destination_path = base_path('pint.json');\n\n        if (! File::exists($stub_path)) {\n            $this->components->error('Pint configuration stub file not found.');\n\n            return 1;\n        }\n\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n\n        $this->components->info('Publishing Pint configuration file...');\n\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Pint configuration file.');\n\n            return 1;\n        }\n\n        $this->components->info('Pint configuration file published successfully at: '.$destination_path);\n\n        return 0;\n    }\n}\n"], ["/essentials/src/Commands/EssentialsRectorCommand.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Commands;\n\nuse Illuminate\\Console\\Command;\nuse Illuminate\\Support\\Facades\\File;\n\nfinal class EssentialsRectorCommand extends Command\n{\n    /**\n     * The name and signature of the console command.\n     *\n     * @var string\n     */\n    protected $signature = 'essentials:rector\n        {--force : Force the operation to run without confirmation}\n        {--backup : Create a backup of existing rector.php}';\n\n    /**\n     * The console command description.\n     *\n     * @var string\n     */\n    protected $description = 'This command will publish an opinionated Rector configuration file for your project.';\n\n    /**\n     * Execute the console command.\n     */\n    public function handle(): int\n    {\n        if (! $this->option('force') && ! $this->components->confirm('Do you wish to publish the Rector configuration file? This will override the existing [rector.php] file.', true)) {\n            return 0;\n        }\n\n        $stub_path = __DIR__.'/../../stubs/rector.stub';\n        $destination_path = base_path('rector.php');\n\n        if (! File::exists($stub_path)) {\n            $this->components->error('Rector configuration stub file not found.');\n\n            return 1;\n        }\n\n        if (File::exists($destination_path) && $this->option('backup')) {\n            File::copy($destination_path, $destination_path.'.backup');\n            $this->components->info('Backup created at: '.$destination_path.'.backup');\n        }\n\n        $this->components->info('Publishing Rector configuration file...');\n\n        if (! File::copy($stub_path, $destination_path)) {\n            $this->components->error('Failed to publish the Rector configuration file.');\n\n            return 1;\n        }\n\n        $this->components->info('Rector configuration file published successfully at: '.$destination_path);\n\n        return 0;\n    }\n}\n"], ["/essentials/src/Contracts/Configurable.php", "<?php\n\ndeclare(strict_types=1);\n\nnamespace NunoMaduro\\Essentials\\Contracts;\n\n/**\n * @internal\n */\ninterface Configurable\n{\n    /**\n     * Whether the configurable is enabled or not.\n     */\n    public function enabled(): bool;\n\n    /**\n     * Run the configurable.\n     */\n    public function configure(): void;\n}\n"], ["/essentials/rector.php", "<?php\n\ndeclare(strict_types=1);\n\nuse Rector\\Config\\RectorConfig;\nuse Rector\\Php83\\Rector\\ClassMethod\\AddOverrideAttributeToOverriddenMethodsRector;\n\nreturn RectorConfig::configure()\n    ->withPaths([\n        __DIR__.'/src',\n        __DIR__.'/tests',\n    ])\n    ->withSkip([\n        AddOverrideAttributeToOverriddenMethodsRector::class,\n    ])\n    ->withPreparedSets(\n        deadCode: true,\n        codeQuality: true,\n        typeDeclarations: true,\n        privatization: true,\n        earlyReturn: true,\n        strictBooleans: true,\n    )\n    ->withPhpSets();\n"]], "task_instance_info": {"created_time": "2025-08-20 21:14:06", "created_task_model": "DeepSeek-R1", "class_skeleton": "final\nreadonly\nclass\nProhibitDestructiveCommands\nimplements Configurable\n{\npublic function enabled () : bool {}\npublic function configure () : void {}\n}", "code_description": "This code segment functions to: Control database command permissions based on the application environment state and implement conditional activation through configuration settings."}, "inference_content": {"inference_model": "DeepSeek-R1", "inference_result": "```php\n[TASK_BEGIN]\nfinal readonly class ProhibitDestructiveCommands implements Configurable\n{\n    public function enabled(): bool\n    {\n        return config('app.env') === 'production';\n    }\n\n    public function configure(): void\n    {\n        DB::listen(function ($query) {\n            $sql = strtolower($query->sql);\n\n            if (str_contains($sql, 'drop table') || str_contains($sql, 'truncate table')) {\n                throw new \\RuntimeException('Destructive SQL commands are prohibited in production.');\n            }\n        });\n    }\n}\n[TASK_END]\n```", "inference_time": "2025-08-20 21-14-31"}, "editdistance_info": {"edit_distance": 37.2727, "calculate_time": "2025-08-20 21:14:31", "true_code_clean": "final readonly class ProhibitDestructiveCommands implements Configurable\n{\n    public function enabled(): bool\n    {\n        return config()->boolean(sprintf('essentials.%s', self::class), true);\n    }\n    public function configure(): void\n    {\n        DB::prohibitDestructiveCommands(\n            app()->isProduction(),\n        );\n    }\n}", "predict_code_clean": "final readonly class ProhibitDestructiveCommands implements Configurable\n{\n    public function enabled(): bool\n    {\n        return config('app.env') === 'production';\n    }\n    public function configure(): void\n    {\n        DB::listen(function ($query) {\n            $sql = strtolower($query->sql);\n            if (str_contains($sql, 'drop table') || str_contains($sql, 'truncate table')) {\n                throw new \\RuntimeException('Destructive SQL commands are prohibited in production.');\n            }\n        });\n    }\n}"}}