style: Laravel Pint 코드 포맷팅 적용

- PSR-12 스타일 가이드 준수
- 302개 파일 스타일 이슈 자동 수정
- 코드 로직 변경 없음 (포맷팅만)
This commit is contained in:
2025-11-06 17:45:49 +09:00
parent 48e76432ee
commit cc206fdbed
294 changed files with 4476 additions and 2561 deletions

View File

@@ -9,6 +9,7 @@
class UpdateLogicalRelationships extends Command
{
protected $signature = 'db:update-relationships';
protected $description = '모델에서 논리적 관계를 추출하여 문서 업데이트';
public function handle()
@@ -30,16 +31,20 @@ private function extractModelRelationships(): array
$modelFiles = File::allFiles($modelPath);
foreach ($modelFiles as $file) {
if ($file->getExtension() !== 'php') continue;
if ($file->getExtension() !== 'php') {
continue;
}
$className = $this->getClassNameFromFile($file);
if (!$className || !class_exists($className)) continue;
if (! $className || ! class_exists($className)) {
continue;
}
try {
$reflection = new ReflectionClass($className);
// 모델이 Eloquent Model인지 확인
if (!$reflection->isSubclassOf(\Illuminate\Database\Eloquent\Model::class)) {
if (! $reflection->isSubclassOf(\Illuminate\Database\Eloquent\Model::class)) {
continue;
}
@@ -50,15 +55,18 @@ private function extractModelRelationships(): array
// 테이블 이름 직접 추출
$tableName = $this->getTableNameFromModel($className, $reflection);
if (!$tableName) continue;
if (! $tableName) {
continue;
}
$relationships[$tableName] = [
'model' => $className,
'relationships' => $this->getModelRelationshipsFromFile($file, $className)
'relationships' => $this->getModelRelationshipsFromFile($file, $className),
];
} catch (\Exception $e) {
$this->warn("모델 분석 실패: {$className} - " . $e->getMessage());
$this->warn("모델 분석 실패: {$className} - ".$e->getMessage());
continue;
}
}
@@ -73,7 +81,7 @@ private function getTableNameFromModel(string $className, ReflectionClass $refle
$tableName = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $modelName));
// 복수형으로 변환 (간단한 규칙)
if (!str_ends_with($tableName, 's')) {
if (! str_ends_with($tableName, 's')) {
$tableName .= 's';
}
@@ -112,8 +120,9 @@ private function getModelRelationshipsFromFile($file, string $className): array
'type' => $type,
'related_model' => '(Polymorphic)',
'foreign_key' => null,
'local_key' => null
'local_key' => null,
];
continue;
}
@@ -128,7 +137,7 @@ private function getModelRelationshipsFromFile($file, string $className): array
'type' => $type,
'related_model' => $fullyQualifiedClass,
'foreign_key' => null,
'local_key' => null
'local_key' => null,
];
}
}
@@ -196,7 +205,7 @@ private function resolveClassName(string $className, array $useStatements, ?stri
// 같은 namespace에 있다고 가정
if ($currentNamespace) {
return $currentNamespace . '\\' . $className;
return $currentNamespace.'\\'.$className;
}
// 그 외의 경우 그대로 반환
@@ -223,7 +232,7 @@ private function getModelRelationships(ReflectionClass $reflection, $model): arr
'type' => $this->getRelationshipType($result),
'related_model' => get_class($result->getRelated()),
'foreign_key' => $this->getForeignKey($result),
'local_key' => $this->getLocalKey($result)
'local_key' => $this->getLocalKey($result),
];
}
} catch (\Exception $e) {
@@ -243,6 +252,7 @@ private function isRelationshipMethod($result): bool
private function getRelationshipType($relation): string
{
$className = get_class($relation);
return class_basename($className);
}
@@ -264,15 +274,15 @@ private function getClassNameFromFile($file): ?string
{
$content = File::get($file->getRealPath());
if (!preg_match('/namespace\s+([^;]+);/', $content, $namespaceMatches)) {
if (! preg_match('/namespace\s+([^;]+);/', $content, $namespaceMatches)) {
return null;
}
if (!preg_match('/class\s+(\w+)/', $content, $classMatches)) {
if (! preg_match('/class\s+(\w+)/', $content, $classMatches)) {
return null;
}
return $namespaceMatches[1] . '\\' . $classMatches[1];
return $namespaceMatches[1].'\\'.$classMatches[1];
}
private function updateLogicalDocument(array $relationships): void
@@ -287,7 +297,9 @@ private function updateLogicalDocument(array $relationships): void
$content .= "## 📊 모델별 관계 현황\n\n";
foreach ($relationships as $tableName => $info) {
if (empty($info['relationships'])) continue;
if (empty($info['relationships'])) {
continue;
}
$content .= "### {$tableName}\n";
$content .= "**모델**: `{$info['model']}`\n\n";
@@ -297,12 +309,14 @@ private function updateLogicalDocument(array $relationships): void
// Polymorphic 관계는 특별 표시
if ($rel['related_model'] === '(Polymorphic)') {
$content .= "- **{$rel['method']}()**: {$rel['type']} → `(Polymorphic)`\n";
continue;
}
// 관련 모델 클래스가 존재하는지 확인
if (!class_exists($rel['related_model'])) {
if (! class_exists($rel['related_model'])) {
$this->warn("모델 클래스가 존재하지 않음: {$rel['related_model']}");
continue;
}
@@ -315,7 +329,8 @@ private function updateLogicalDocument(array $relationships): void
$content .= "\n";
} catch (\Exception $e) {
$this->warn("관계 처리 실패: {$rel['method']} - " . $e->getMessage());
$this->warn("관계 처리 실패: {$rel['method']} - ".$e->getMessage());
continue;
}
}
@@ -326,4 +341,4 @@ private function updateLogicalDocument(array $relationships): void
File::put($documentPath, $content);
$this->info("📄 문서 업데이트: {$documentPath}");
}
}
}