Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Dec 27, 2023
1 parent d4c3325 commit bfba3c6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"php": "^8.1",
"composer-runtime-api": "^2.2",
"composer/semver": "^3.0",
"illuminate/console": "^10.26",
"illuminate/filesystem": "^10.26",
"illuminate/console": "^10.38.1",
"illuminate/filesystem": "^10.38.1",
"symfony/polyfill-php83": "^1.28"
},
"require-dev": {
"laravel/pint": "^1.6",
"laravel/framework": "^10.26",
"laravel/framework": "^10.38.1",
"mockery/mockery": "^1.5.1",
"orchestra/testbench-core": "^8.15",
"phpstan/phpstan": "^1.10.6",
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Illuminate\\\\Contracts\\\\Foundation\\\\Application\\:\\:joinPaths\\(\\)\\.$#"
count: 1
path: src/Commands/MigrationGeneratorCommand.php

-
message: "#^Cannot access offset 'migration\\.creator' on Illuminate\\\\Contracts\\\\Foundation\\\\Application\\.$#"
count: 1
Expand Down
4 changes: 3 additions & 1 deletion src/Concerns/MigrationGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Orchestra\Canvas\Core\Concerns;

use function Illuminate\Filesystem\join_paths;

trait MigrationGenerator
{
use CreatesUsingGeneratorPreset;
Expand All @@ -22,7 +24,7 @@ protected function createBaseMigrationUsingCanvas(string $table): string
protected function migrationExistsUsingCanvas(string $table): bool
{
return \count($this->files->glob(
$this->laravel->joinPaths($this->generatorPreset()->migrationPath(), '*_*_*_*_create_'.$table.'_table.php')
join_paths($this->generatorPreset()->migrationPath(), '*_*_*_*_create_'.$table.'_table.php')
)) !== 0;
}
}
4 changes: 3 additions & 1 deletion src/Concerns/ResolvesPresetStubs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Orchestra\Canvas\Core\Concerns;

use function Illuminate\Filesystem\join_paths;

trait ResolvesPresetStubs
{
/**
Expand All @@ -14,7 +16,7 @@ protected function resolveStubPath($stub)
{
$preset = $this->generatorPreset();

return $preset->hasCustomStubPath() && file_exists($customPath = implode('/', [$preset->basePath(), trim($stub, '/')]))
return $preset->hasCustomStubPath() && file_exists($customPath = join_paths($preset->basePath(), trim($stub, '/')))
? $customPath
: $this->resolveDefaultStubPath($stub);
}
Expand Down
10 changes: 6 additions & 4 deletions src/Concerns/UsesGeneratorOverrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Orchestra\Canvas\Core\Presets\Preset;
use Symfony\Component\Finder\Finder;

use function Illuminate\Filesystem\join_paths;

trait UsesGeneratorOverrides
{
/**
Expand All @@ -31,7 +33,7 @@ protected function getPathUsingCanvas(string $name): string
{
$name = Str::replaceFirst($this->rootNamespace(), '', $name);

return $this->getGeneratorSourcePath().'/'.str_replace('\\', '/', $name).'.php';
return join_paths($this->getGeneratorSourcePath(), str_replace('\\', '/', $name).'.php');
}

/**
Expand All @@ -57,7 +59,7 @@ protected function viewPathUsingCanvas(string $path = ''): string
{
$views = $this->generatorPreset()->viewPath();

return $views.($path ? DIRECTORY_SEPARATOR.$path : $path);
return join_paths($views, $path);
}

/**
Expand All @@ -69,7 +71,7 @@ protected function possibleModelsUsingCanvas(): array
{
$sourcePath = $this->generatorPreset()->sourcePath();

$modelPath = is_dir("{$sourcePath}/Models") ? "{$sourcePath}/Models" : $sourcePath;
$modelPath = is_dir(join_paths($sourcePath, 'Models')) ? join_paths($sourcePath, 'Models') : $sourcePath;

return collect((new Finder)->files()->depth(0)->in($modelPath))
->map(fn ($file) => $file->getBasename('.php'))
Expand All @@ -85,7 +87,7 @@ protected function possibleModelsUsingCanvas(): array
*/
protected function possibleEventsUsingCanvas(): array
{
$eventPath = sprintf('%s/Events', $this->generatorPreset()->sourcePath());
$eventPath = join_paths($this->generatorPreset()->sourcePath(), 'Events');

if (! is_dir($eventPath)) {
return [];
Expand Down
4 changes: 3 additions & 1 deletion src/Presets/Laravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Orchestra\Canvas\Core\Presets;

use function Illuminate\Filesystem\join_paths;

class Laravel extends Preset
{
/**
Expand Down Expand Up @@ -123,7 +125,7 @@ public function commandNamespace()
*/
public function modelNamespace()
{
return is_dir("{$this->sourcePath()}/Models") ? "{$this->rootNamespace()}Models\\" : $this->rootNamespace();
return is_dir(join_paths($this->sourcePath(), 'Models')) ? "{$this->rootNamespace()}Models\\" : $this->rootNamespace();
}

/**
Expand Down

0 comments on commit bfba3c6

Please sign in to comment.