Skip to content

Commit

Permalink
fix(phpstan): error on return and param
Browse files Browse the repository at this point in the history
  • Loading branch information
holiq committed Oct 7, 2023
1 parent 3bc7b70 commit cd3091b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Actions/Stub/ReplacePlaceholderAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function ($value, $key) use (&$stub) {
}
);

/** @var string $contents */
$contents = $stub;

$filesystem->ensureDirectoryExists(path: Str::of($filePath)->beforeLast(search: '/'));
Expand Down
2 changes: 2 additions & 0 deletions src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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 @@ -95,6 +96,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(),
Expand Down
20 changes: 16 additions & 4 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 $result */
$result = 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 $result;
}

public static function resolveNamespaceDir(NamespaceData $data, string $namespace): string
Expand All @@ -72,11 +75,14 @@ public static function resolveNamespacePath(string $namespace): string

public static function transformNamespaceToPath(string $namespace): string
{
return Str::replace(
/** @var string $result */
$result = Str::replace(
search: '\\',
replace: '/',
subject: $namespace
);

return $result;
}

public static function resolveNameFromPHP(string $name): string
Expand All @@ -86,11 +92,17 @@ public static function resolveNameFromPHP(string $name): string

public static function resolveNameFromFile(string $name, string $suffix): string
{
return Str::replace(search: Str::start($suffix, prefix: '.'), replace: '', subject: $name);
/** @var string $result */
$result = Str::replace(search: Str::start($suffix, prefix: '.'), replace: '', subject: $name);

return $result;
}

public static function resolveStubForPath(string $name): string
{
return Str::replace(search: ':name', replace: $name, subject: __DIR__ . '/../../stubs/:name.stub');
/** @var string $result */
$result = Str::replace(search: ':name', replace: $name, subject: __DIR__ . '/../../stubs/:name.stub');

return $result;
}
}

0 comments on commit cd3091b

Please sign in to comment.