From 9ba6b57d0d9fc43d89e18ceb854c57ee22bf0d5b Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Wed, 3 Dec 2025 22:52:59 +0000 Subject: [PATCH] style: format code with PHP CS Fixer This commit fixes the style issues introduced in 6dd658f according to the output from PHP CS Fixer. Details: None --- config/reversekit.php | 1 - examples/generated/app/Http/Controllers/PostController.php | 1 - examples/generated/app/Http/Controllers/UserController.php | 1 - examples/generated/app/Http/Resources/PostResource.php | 1 - examples/generated/app/Http/Resources/UserResource.php | 1 - examples/generated/app/Models/Post.php | 1 - examples/generated/app/Models/User.php | 1 - examples/generated/app/Policies/PostPolicy.php | 1 - examples/generated/app/Policies/UserPolicy.php | 1 - .../migrations/2024_01_01_000001_create_users_table.php | 4 +--- .../migrations/2024_01_01_000002_create_posts_table.php | 4 +--- examples/generated/routes/api.php | 1 - examples/generated/tests/Feature/PostTest.php | 1 - examples/generated/tests/Feature/UserTest.php | 1 - src/Commands/ReverseGenerateCommand.php | 5 ++--- src/Commands/ReverseInteractiveCommand.php | 4 ++-- src/Contracts/ParserInterface.php | 1 - src/Generators/BaseGenerator.php | 3 +-- src/Generators/ControllerGenerator.php | 1 - src/Generators/FactoryGenerator.php | 1 - src/Generators/FormRequestGenerator.php | 1 - src/Generators/MigrationGenerator.php | 1 - src/Generators/ModelGenerator.php | 7 +++---- src/Generators/PolicyGenerator.php | 1 - src/Generators/ResourceGenerator.php | 1 - src/Generators/RouteGenerator.php | 3 +-- src/Generators/SeederGenerator.php | 1 - src/Generators/TestGenerator.php | 3 +-- src/Http/Controllers/Controller.php | 4 ++-- src/Parsers/ApiUrlParser.php | 4 ++-- src/Parsers/DatabaseParser.php | 5 +++-- src/Parsers/JsonParser.php | 4 ++-- src/Parsers/OpenApiParser.php | 3 ++- src/Parsers/PostmanParser.php | 3 ++- src/ReverseKitServiceProvider.php | 1 - src/Support/RelationshipDetector.php | 4 ++-- src/Support/TypeInferrer.php | 1 - 37 files changed, 27 insertions(+), 55 deletions(-) diff --git a/config/reversekit.php b/config/reversekit.php index e139a47..4358ffa 100644 --- a/config/reversekit.php +++ b/config/reversekit.php @@ -147,4 +147,3 @@ ], ]; - diff --git a/examples/generated/app/Http/Controllers/PostController.php b/examples/generated/app/Http/Controllers/PostController.php index b5dba23..d1db1eb 100644 --- a/examples/generated/app/Http/Controllers/PostController.php +++ b/examples/generated/app/Http/Controllers/PostController.php @@ -76,4 +76,3 @@ public function destroy(Post $post): JsonResponse return response()->json(null, 204); } } - diff --git a/examples/generated/app/Http/Controllers/UserController.php b/examples/generated/app/Http/Controllers/UserController.php index a2c5500..efaac94 100644 --- a/examples/generated/app/Http/Controllers/UserController.php +++ b/examples/generated/app/Http/Controllers/UserController.php @@ -72,4 +72,3 @@ public function destroy(User $user): JsonResponse return response()->json(null, 204); } } - diff --git a/examples/generated/app/Http/Resources/PostResource.php b/examples/generated/app/Http/Resources/PostResource.php index 25a27f7..e82bd48 100644 --- a/examples/generated/app/Http/Resources/PostResource.php +++ b/examples/generated/app/Http/Resources/PostResource.php @@ -29,4 +29,3 @@ public function toArray(Request $request): array ]; } } - diff --git a/examples/generated/app/Http/Resources/UserResource.php b/examples/generated/app/Http/Resources/UserResource.php index aa5032e..e924bcc 100644 --- a/examples/generated/app/Http/Resources/UserResource.php +++ b/examples/generated/app/Http/Resources/UserResource.php @@ -27,4 +27,3 @@ public function toArray(Request $request): array ]; } } - diff --git a/examples/generated/app/Models/Post.php b/examples/generated/app/Models/Post.php index 2313224..ad96eba 100644 --- a/examples/generated/app/Models/Post.php +++ b/examples/generated/app/Models/Post.php @@ -33,4 +33,3 @@ public function user(): BelongsTo return $this->belongsTo(User::class, 'user_id'); } } - diff --git a/examples/generated/app/Models/User.php b/examples/generated/app/Models/User.php index 7295d1b..de9f629 100644 --- a/examples/generated/app/Models/User.php +++ b/examples/generated/app/Models/User.php @@ -29,4 +29,3 @@ public function posts(): HasMany return $this->hasMany(Post::class, 'user_id'); } } - diff --git a/examples/generated/app/Policies/PostPolicy.php b/examples/generated/app/Policies/PostPolicy.php index f9f48cf..3daf3cc 100644 --- a/examples/generated/app/Policies/PostPolicy.php +++ b/examples/generated/app/Policies/PostPolicy.php @@ -68,4 +68,3 @@ public function forceDelete(User $user, Post $post): bool return $user->id === $post->user_id; } } - diff --git a/examples/generated/app/Policies/UserPolicy.php b/examples/generated/app/Policies/UserPolicy.php index 6aff768..bf71cda 100644 --- a/examples/generated/app/Policies/UserPolicy.php +++ b/examples/generated/app/Policies/UserPolicy.php @@ -67,4 +67,3 @@ public function forceDelete(User $user, User $model): bool return true; } } - diff --git a/examples/generated/database/migrations/2024_01_01_000001_create_users_table.php b/examples/generated/database/migrations/2024_01_01_000001_create_users_table.php index 05abef5..99e13fe 100644 --- a/examples/generated/database/migrations/2024_01_01_000001_create_users_table.php +++ b/examples/generated/database/migrations/2024_01_01_000001_create_users_table.php @@ -4,8 +4,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class () extends Migration { /** * Run the migrations. */ @@ -27,4 +26,3 @@ public function down(): void Schema::dropIfExists('users'); } }; - diff --git a/examples/generated/database/migrations/2024_01_01_000002_create_posts_table.php b/examples/generated/database/migrations/2024_01_01_000002_create_posts_table.php index cf190ff..ba86076 100644 --- a/examples/generated/database/migrations/2024_01_01_000002_create_posts_table.php +++ b/examples/generated/database/migrations/2024_01_01_000002_create_posts_table.php @@ -4,8 +4,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -return new class extends Migration -{ +return new class () extends Migration { /** * Run the migrations. */ @@ -29,4 +28,3 @@ public function down(): void Schema::dropIfExists('posts'); } }; - diff --git a/examples/generated/routes/api.php b/examples/generated/routes/api.php index 405dd38..b8d90e4 100644 --- a/examples/generated/routes/api.php +++ b/examples/generated/routes/api.php @@ -7,4 +7,3 @@ Route::apiResource('users', \App\Http\Controllers\UserController::class); Route::apiResource('posts', \App\Http\Controllers\PostController::class); - diff --git a/examples/generated/tests/Feature/PostTest.php b/examples/generated/tests/Feature/PostTest.php index 6ac163f..9c9f6f6 100644 --- a/examples/generated/tests/Feature/PostTest.php +++ b/examples/generated/tests/Feature/PostTest.php @@ -113,4 +113,3 @@ public function test_can_delete_post(): void $this->assertDatabaseMissing('posts', ['id' => $post->id]); } } - diff --git a/examples/generated/tests/Feature/UserTest.php b/examples/generated/tests/Feature/UserTest.php index 07008da..cbbe1b1 100644 --- a/examples/generated/tests/Feature/UserTest.php +++ b/examples/generated/tests/Feature/UserTest.php @@ -102,4 +102,3 @@ public function test_can_delete_user(): void $this->assertDatabaseMissing('users', ['id' => $targetUser->id]); } } - diff --git a/src/Commands/ReverseGenerateCommand.php b/src/Commands/ReverseGenerateCommand.php index a365819..6842efc 100644 --- a/src/Commands/ReverseGenerateCommand.php +++ b/src/Commands/ReverseGenerateCommand.php @@ -433,11 +433,10 @@ private function displaySummary(): void $this->newLine(); $this->info('📊 Generation Summary:'); - $created = count(array_filter($this->generatedFiles, fn($f) => $f['created'])); - $skipped = count(array_filter($this->generatedFiles, fn($f) => $f['existed'] && !$f['created'])); + $created = count(array_filter($this->generatedFiles, fn ($f) => $f['created'])); + $skipped = count(array_filter($this->generatedFiles, fn ($f) => $f['existed'] && !$f['created'])); $this->line(" ✓ Created: {$created} files"); $this->line(" ○ Skipped: {$skipped} files (already existed)"); } } - diff --git a/src/Commands/ReverseInteractiveCommand.php b/src/Commands/ReverseInteractiveCommand.php index 583bb80..524074a 100644 --- a/src/Commands/ReverseInteractiveCommand.php +++ b/src/Commands/ReverseInteractiveCommand.php @@ -155,7 +155,7 @@ private function collectEntities(RelationshipDetector $relationshipDetector): vo label: 'Enter model name (e.g., User, BlogPost)', placeholder: 'User', required: true, - validate: fn(string $value) => preg_match('/^[A-Z][a-zA-Z0-9]*$/', $value) + validate: fn (string $value) => preg_match('/^[A-Z][a-zA-Z0-9]*$/', $value) ? null : 'Model name must be PascalCase (e.g., User, BlogPost)' ); @@ -213,7 +213,7 @@ private function collectFields(string $entityName): array label: 'Field name (snake_case)', placeholder: 'title', required: true, - validate: fn(string $value) => preg_match('/^[a-z][a-z0-9_]*$/', $value) + validate: fn (string $value) => preg_match('/^[a-z][a-z0-9_]*$/', $value) ? null : 'Field name must be snake_case (e.g., title, created_at)' ); diff --git a/src/Contracts/ParserInterface.php b/src/Contracts/ParserInterface.php index 32365bc..bcd744b 100644 --- a/src/Contracts/ParserInterface.php +++ b/src/Contracts/ParserInterface.php @@ -20,4 +20,3 @@ public function parse(string $input): array; */ public function getEntities(): array; } - diff --git a/src/Generators/BaseGenerator.php b/src/Generators/BaseGenerator.php index 28fc92f..272b2b8 100644 --- a/src/Generators/BaseGenerator.php +++ b/src/Generators/BaseGenerator.php @@ -136,7 +136,7 @@ protected function indent(string $code, int $levels = 1): string { $indent = str_repeat(' ', $levels); $lines = explode("\n", $code); - return implode("\n", array_map(fn($line) => $line ? $indent . $line : $line, $lines)); + return implode("\n", array_map(fn ($line) => $line ? $indent . $line : $line, $lines)); } /** @@ -171,4 +171,3 @@ protected function getPath(string $className): string return $this->getBasePath() . '/' . $className . '.php'; } } - diff --git a/src/Generators/ControllerGenerator.php b/src/Generators/ControllerGenerator.php index 0472cf5..2f995cc 100644 --- a/src/Generators/ControllerGenerator.php +++ b/src/Generators/ControllerGenerator.php @@ -175,4 +175,3 @@ private function getFieldRules(string $fieldName, array $field): string return implode('|', $rules); } } - diff --git a/src/Generators/FactoryGenerator.php b/src/Generators/FactoryGenerator.php index 6b1ca66..c127a80 100644 --- a/src/Generators/FactoryGenerator.php +++ b/src/Generators/FactoryGenerator.php @@ -248,4 +248,3 @@ protected function getPath(string $className): string return database_path('factories/' . $className . '.php'); } } - diff --git a/src/Generators/FormRequestGenerator.php b/src/Generators/FormRequestGenerator.php index acc404a..d895564 100644 --- a/src/Generators/FormRequestGenerator.php +++ b/src/Generators/FormRequestGenerator.php @@ -150,4 +150,3 @@ protected function getPath(string $className): string return $this->getBasePath() . '/Http/Requests/' . $className . '.php'; } } - diff --git a/src/Generators/MigrationGenerator.php b/src/Generators/MigrationGenerator.php index 00cf4d6..ae072d1 100644 --- a/src/Generators/MigrationGenerator.php +++ b/src/Generators/MigrationGenerator.php @@ -182,4 +182,3 @@ public static function resetOrder(): void self::$migrationOrder = 0; } } - diff --git a/src/Generators/ModelGenerator.php b/src/Generators/ModelGenerator.php index cf6cbdd..751ce48 100644 --- a/src/Generators/ModelGenerator.php +++ b/src/Generators/ModelGenerator.php @@ -57,7 +57,7 @@ private function generateContent(array $entity): string } sort($uses); - $useStatements = implode("\n", array_map(fn($use) => "use {$use};", $uses)); + $useStatements = implode("\n", array_map(fn ($use) => "use {$use};", $uses)); $content = << $name !== 'id' && !in_array($name, ['created_at', 'updated_at']) + fn ($name) => $name !== 'id' && !in_array($name, ['created_at', 'updated_at']) ); if (empty($fillableFields)) { return " protected \$fillable = [];"; } - $items = array_map(fn($field) => " '{$field}',", $fillableFields); + $items = array_map(fn ($field) => " '{$field}',", $fillableFields); $itemsString = implode("\n", $items); return <<id === \${$modelVar}->user_id"; } } - diff --git a/src/Generators/ResourceGenerator.php b/src/Generators/ResourceGenerator.php index e02bca5..518abc3 100644 --- a/src/Generators/ResourceGenerator.php +++ b/src/Generators/ResourceGenerator.php @@ -104,4 +104,3 @@ private function generateFieldsArray(array $entity): string return "[\n{$fieldsString}\n ]"; } } - diff --git a/src/Generators/RouteGenerator.php b/src/Generators/RouteGenerator.php index c56585d..0852911 100644 --- a/src/Generators/RouteGenerator.php +++ b/src/Generators/RouteGenerator.php @@ -75,7 +75,7 @@ public function generateAll(array $entities, bool $force = false): array */ private function generateRouteBlock(array $entities, array $routes): string { - $modelNames = implode(', ', array_map(fn($e) => $e['name'], $entities)); + $modelNames = implode(', ', array_map(fn ($e) => $e['name'], $entities)); $timestamp = date('Y-m-d H:i:s'); $block = "\n\n// ReverseKit Generated Routes ({$timestamp})"; @@ -129,4 +129,3 @@ private function createApiRouteFile(string $path, string $routeContent): void file_put_contents($path, $content); } } - diff --git a/src/Generators/SeederGenerator.php b/src/Generators/SeederGenerator.php index 6035b3b..a2e906c 100644 --- a/src/Generators/SeederGenerator.php +++ b/src/Generators/SeederGenerator.php @@ -141,4 +141,3 @@ public function run(): void PHP; } } - diff --git a/src/Generators/TestGenerator.php b/src/Generators/TestGenerator.php index b97f590..fa4d9fb 100644 --- a/src/Generators/TestGenerator.php +++ b/src/Generators/TestGenerator.php @@ -204,7 +204,7 @@ private function generateAssertFields(array $fields): string { $fieldNames = array_filter( array_keys($fields), - fn($name) => !in_array($name, ['created_at', 'updated_at']) + fn ($name) => !in_array($name, ['created_at', 'updated_at']) ); return "'" . implode("', '", $fieldNames) . "'"; @@ -241,4 +241,3 @@ private function getUpdatedValue(string $fieldName, array $field): string }; } } - diff --git a/src/Http/Controllers/Controller.php b/src/Http/Controllers/Controller.php index e9cf4e0..7f41f3c 100644 --- a/src/Http/Controllers/Controller.php +++ b/src/Http/Controllers/Controller.php @@ -10,6 +10,6 @@ abstract class Controller extends BaseController { - use AuthorizesRequests, ValidatesRequests; + use AuthorizesRequests; + use ValidatesRequests; } - diff --git a/src/Parsers/ApiUrlParser.php b/src/Parsers/ApiUrlParser.php index 7f328a3..20ce010 100644 --- a/src/Parsers/ApiUrlParser.php +++ b/src/Parsers/ApiUrlParser.php @@ -14,7 +14,8 @@ class ApiUrlParser implements ParserInterface public function __construct( private JsonParser $jsonParser - ) {} + ) { + } /** * Parse JSON from a URL. @@ -112,4 +113,3 @@ public function getEntities(): array return $this->entities; } } - diff --git a/src/Parsers/DatabaseParser.php b/src/Parsers/DatabaseParser.php index 6ed4e73..6c15824 100644 --- a/src/Parsers/DatabaseParser.php +++ b/src/Parsers/DatabaseParser.php @@ -15,7 +15,8 @@ class DatabaseParser implements ParserInterface public function __construct( private RelationshipDetector $relationshipDetector - ) {} + ) { + } /** * Parse database tables. @@ -60,7 +61,7 @@ private function getTables(string $input): array if ($input === '*') { $allTables = Schema::getTableListing(); - return array_filter($allTables, fn($table) => !in_array($table, $excludedTables)); + return array_filter($allTables, fn ($table) => !in_array($table, $excludedTables)); } $requestedTables = array_map('trim', explode(',', $input)); diff --git a/src/Parsers/JsonParser.php b/src/Parsers/JsonParser.php index faafaad..95283bf 100644 --- a/src/Parsers/JsonParser.php +++ b/src/Parsers/JsonParser.php @@ -20,7 +20,8 @@ class JsonParser public function __construct( private TypeInferrer $typeInferrer, private RelationshipDetector $relationshipDetector - ) {} + ) { + } /** * Parse JSON content and extract entities. @@ -219,4 +220,3 @@ public function getEntities(): array return $this->entities; } } - diff --git a/src/Parsers/OpenApiParser.php b/src/Parsers/OpenApiParser.php index 1ae9de3..60ae0e9 100644 --- a/src/Parsers/OpenApiParser.php +++ b/src/Parsers/OpenApiParser.php @@ -18,7 +18,8 @@ class OpenApiParser implements ParserInterface public function __construct( private TypeInferrer $typeInferrer, private RelationshipDetector $relationshipDetector - ) {} + ) { + } /** * Parse OpenAPI/Swagger specification file. diff --git a/src/Parsers/PostmanParser.php b/src/Parsers/PostmanParser.php index ec08b44..0a77ccc 100644 --- a/src/Parsers/PostmanParser.php +++ b/src/Parsers/PostmanParser.php @@ -17,7 +17,8 @@ class PostmanParser implements ParserInterface public function __construct( private TypeInferrer $typeInferrer, private RelationshipDetector $relationshipDetector - ) {} + ) { + } /** * Parse Postman collection file. diff --git a/src/ReverseKitServiceProvider.php b/src/ReverseKitServiceProvider.php index 4dea5c4..37af161 100644 --- a/src/ReverseKitServiceProvider.php +++ b/src/ReverseKitServiceProvider.php @@ -108,4 +108,3 @@ public function boot(): void } } } - diff --git a/src/Support/RelationshipDetector.php b/src/Support/RelationshipDetector.php index ee70a8b..e8aba96 100644 --- a/src/Support/RelationshipDetector.php +++ b/src/Support/RelationshipDetector.php @@ -8,7 +8,8 @@ class RelationshipDetector { public function __construct( private TypeInferrer $typeInferrer - ) {} + ) { + } /** * Detect relationships from JSON structure. @@ -180,4 +181,3 @@ public function toCamelCase(string $string): string return lcfirst($this->toPascalCase($string)); } } - diff --git a/src/Support/TypeInferrer.php b/src/Support/TypeInferrer.php index 459b224..5b8d4eb 100644 --- a/src/Support/TypeInferrer.php +++ b/src/Support/TypeInferrer.php @@ -190,4 +190,3 @@ public function isAssociativeArray(array $arr): bool return array_keys($arr) !== range(0, count($arr) - 1); } } -