diff --git a/src/Actions/Stub/ReplacePlaceholderAction.php b/src/Actions/Stub/ReplacePlaceholderAction.php index 9b0dc6f..34249f6 100644 --- a/src/Actions/Stub/ReplacePlaceholderAction.php +++ b/src/Actions/Stub/ReplacePlaceholderAction.php @@ -27,6 +27,7 @@ public function execute(string $filePath, PlaceholderData $placeholders): void $resolved = $placeholders->toArray(); + /**@var string $stub */ $stub = $filesystem->get(path: $filePath); Collection::make($resolved) diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index 147e717..556dc48 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -82,6 +82,7 @@ protected function resolveRefactor(): void $filesystem->ensureDirectoryExists($this->resolveInfrastructurePath()); $filesystem->moveDirectory(from: app_path(path: 'Providers'), to: $this->resolveInfrastructurePath()); $configPath = base_path(path: '/config/app.php'); + /**@var string $contents */ $contents = Str::replace( search: 'App\\Providers', replace: $this->resolveNamespace(), @@ -91,6 +92,7 @@ protected function resolveRefactor(): void $filesystem->put(path: $configPath, contents: $contents); foreach ($filesystem->files($this->resolveInfrastructurePath()) as $file) { + /**@var string $contents */ $contents = Str::replace( search: 'App\\Providers', replace: $this->resolveNamespace(), diff --git a/src/Support/Source.php b/src/Support/Source.php index d5b9ad0..65cbc19 100644 --- a/src/Support/Source.php +++ b/src/Support/Source.php @@ -41,7 +41,8 @@ public static function resolveApplicationPath(): string public static function resolveNamespace(NamespaceData $data): string { - return Str::replace( + /**@var string $namespace */ + $namespace = Str::replace( search: '/', replace: '\\', subject: static::resolveNamespaceDir( @@ -52,6 +53,8 @@ public static function resolveNamespace(NamespaceData $data): string ->finish(cap: $data->endsWith ? '/' . $data->endsWith : '') ) ); + + return $namespace; } public static function resolveNamespaceDir(NamespaceData $data, string $namespace): string @@ -65,32 +68,47 @@ public static function resolveNamespaceDir(NamespaceData $data, string $namespac public static function resolveNamespacePath(string $namespace): string { - return base_path( + /**@var string $path */ + $path = base_path( path: static::resolveBasePath() . static::transformNamespaceToPath(namespace: $namespace) ); + + return $path; } public static function transformNamespaceToPath(string $namespace): string { - return Str::replace( + /**@var string $path */ + $path = Str::replace( search: '\\', replace: '/', subject: $namespace ); + + return $path; } public static function resolveNameFromPHP(string $name): string { - return static::resolveNameFromFile(name: $name, suffix: 'php'); + /**@var string $name */ + $name = static::resolveNameFromFile(name: $name, suffix: 'php'); + + return $name; } public static function resolveNameFromFile(string $name, string $suffix): string { - return Str::replace(search: Str::start($suffix, prefix: '.'), replace: '', subject: $name); + /**@var string $name */ + $name = Str::replace(search: Str::start($suffix, prefix: '.'), replace: '', subject: $name); + + return $name; } public static function resolveStubForPath(string $name): string { - return Str::replace(search: ':name', replace: $name, subject: __DIR__ . '/../../stubs/:name.stub'); + /**@var string $path */ + $path = Str::replace(search: ':name', replace: $name, subject: __DIR__ . '/../../stubs/:name.stub'); + + return $path; } }