Skip to content

Commit

Permalink
fix: phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
pemudakoding authored Dec 19, 2024
1 parent 451a1c1 commit 018552b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/Actions/Stub/ReplacePlaceholderAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -91,6 +92,7 @@ protected function resolveRefactor(): void
$filesystem->put(path: $configPath, contents: $contents);

Check failure on line 92 in src/Commands/InstallCommand.php

View workflow job for this annotation

GitHub Actions / static-analysis

Parameter $contents of method Illuminate\Filesystem\Filesystem::put() expects string, array<string>|string given.

foreach ($filesystem->files($this->resolveInfrastructurePath()) as $file) {
/**@var string $contents */
$contents = Str::replace(
search: 'App\\Providers',
replace: $this->resolveNamespace(),
Expand Down
30 changes: 24 additions & 6 deletions src/Support/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -52,6 +53,8 @@ public static function resolveNamespace(NamespaceData $data): string
->finish(cap: $data->endsWith ? '/' . $data->endsWith : '')
)
);

return $namespace;

Check failure on line 57 in src/Support/Source.php

View workflow job for this annotation

GitHub Actions / static-analysis

Method KoalaFacade\DiamondConsole\Support\Source::resolveNamespace() should return string but returns array<string>|string.
}

public static function resolveNamespaceDir(NamespaceData $data, string $namespace): string
Expand All @@ -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;

Check failure on line 88 in src/Support/Source.php

View workflow job for this annotation

GitHub Actions / static-analysis

Method KoalaFacade\DiamondConsole\Support\Source::transformNamespaceToPath() should return string but returns array<string>|string.
}

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;

Check failure on line 104 in src/Support/Source.php

View workflow job for this annotation

GitHub Actions / static-analysis

Method KoalaFacade\DiamondConsole\Support\Source::resolveNameFromFile() should return string but returns array<string>|string.
}

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;

Check failure on line 112 in src/Support/Source.php

View workflow job for this annotation

GitHub Actions / static-analysis

Method KoalaFacade\DiamondConsole\Support\Source::resolveStubForPath() should return string but returns array<string>|string.
}
}

0 comments on commit 018552b

Please sign in to comment.