From 7bdc788695bafae2978ced3c4c0c663cb35f2f69 Mon Sep 17 00:00:00 2001 From: Anders Jurisoo Date: Sat, 23 Apr 2022 09:28:40 +0200 Subject: [PATCH 1/2] Don't proxy make methods on PHPFile --- src/PHPFile.php | 13 ++++--------- src/Traits/HasSyntacticSweeteners.php | 5 ----- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/PHPFile.php b/src/PHPFile.php index dd5efb6..9a99577 100644 --- a/src/PHPFile.php +++ b/src/PHPFile.php @@ -35,6 +35,8 @@ class PHPFile protected string $fileQueryBuilder = Endpoints\PHP\PHPFileQueryBuilder::class; + protected string $maker = Endpoints\PHP\Make::class; + public string $astQueryBuilder = ASTQueryBuilder::class; protected $ast; @@ -80,17 +82,10 @@ public function getReflection() $handler = new ReflectionProxy($this); return $handler->getReflection(); } - - public function file(string $name = 'dummy.php') - { - $handler = new Make($this); - return $handler->file($name); - } - public function class($name = \App\Dummy::class) + public function make() { - $handler = new Make($this); - return $handler->class($name); + return new $this->maker($this); } public function __construct( diff --git a/src/Traits/HasSyntacticSweeteners.php b/src/Traits/HasSyntacticSweeteners.php index cedb115..262c568 100644 --- a/src/Traits/HasSyntacticSweeteners.php +++ b/src/Traits/HasSyntacticSweeteners.php @@ -39,11 +39,6 @@ public function it() return $this; } - public function make() - { - return $this; - } - public function please() { return $this; From be4143719c83af45f7cfb1282f19b507a1707141 Mon Sep 17 00:00:00 2001 From: Anders Jurisoo Date: Sat, 23 Apr 2022 09:28:54 +0200 Subject: [PATCH 2/2] Remove LaravelMake until properly implemented --- src/Endpoints/Laravel/LaravelMake.php | 95 --------------------------- 1 file changed, 95 deletions(-) delete mode 100644 src/Endpoints/Laravel/LaravelMake.php diff --git a/src/Endpoints/Laravel/LaravelMake.php b/src/Endpoints/Laravel/LaravelMake.php deleted file mode 100644 index 5120a07..0000000 --- a/src/Endpoints/Laravel/LaravelMake.php +++ /dev/null @@ -1,95 +0,0 @@ -setupNames($name); - $this->command = $options['command'] ?? 'command:name'; - - $contents = Str::of($this->stub('console.stub')) - ->replace(['DummyNamespace', '{{ namespace }}'], $this->namespace) - ->replace(['{{ class }}', 'DummyClass'], $this->class) - ->replace(['{{ command }}', 'dummy:command'], $this->command) - ->__toString(); - - return $this->file->fromString($contents) - ->outputDriver($this->outputDriver); - } - - public function model($name) - { - $this->setupNames($name); - - $contents = Str::of($this->stub('model.stub')) - ->replace(['DummyNamespace', '{{ namespace }}'], $this->namespace) - ->replace(['{{ class }}', 'DummyClass'], $this->class) - ->__toString(); - - return $this->file->fromString($contents) - ->outputDriver($this->outputDriver); - } - - public function controller($name) - { - $this->setupNames($name); - - $contents = Str::of($this->stub('controller.plain.stub')) - ->replace(['DummyNamespace', '{{ namespace }}'], $this->namespace) - ->replace(['{{ rootNamespace }}'], $this->namespace) - ->replace(['{{ class }}', 'DummyClass'], $this->class) - ->__toString(); - - return $this->file->fromString($contents) - ->outputDriver($this->outputDriver); - } - - public function migration($name) - { - $this->setupNames($name); - - $contents = Str::of($this->stub('migration.stub')) - ->replace(['DummyNamespace', '{{ namespace }}'], $this->namespace) - ->replace(['{{ rootNamespace }}'], $this->namespace) - ->replace(['{{ class }}', 'DummyClass'], $this->class) - ->__toString(); - - return $this->file->fromString($contents) - ->outputDriver($this->outputDriver); - } - - public function factory($name) - { - $this->setupNames($name); - - $contents = Str::of($this->stub('factory.stub')) - ->replace(['{{ rootNamespace }}'], $this->namespace) - ->__toString(); - - return $this->file->fromString($contents) - ->outputDriver($this->outputDriver); - } - - protected function stub($name) - { - $dir = collect([ - 'stubs', - 'vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs', - 'vendor/laravel/framework/src/Illuminate/Routing/Console/stubs', - 'vendor/laravel/framework/src/Illuminate/Foundation/Console/stubs', - 'vendor/laravel/framework/src/Illuminate/Database/Migrations/stubs', - 'vendor/laravel/framework/src/Illuminate/Database/Console/Factories/stubs', - ])->first(function ($dir) use ($name) { - return is_file(base_path($dir . "/$name")); - }); - - return file_get_contents( - base_path($dir . "/$name") - ); - } -}