From a6b3988f24e84910ad52919ec4fa6fc6497eb8e1 Mon Sep 17 00:00:00 2001 From: imamberdiev Date: Mon, 3 Jul 2023 14:11:48 +0300 Subject: [PATCH 1/2] #108364 fix request generating --- src/Generators/BaseGenerator.php | 6 +++--- tests/GenerateServerTest.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Generators/BaseGenerator.php b/src/Generators/BaseGenerator.php index 2c94e27..277c140 100644 --- a/src/Generators/BaseGenerator.php +++ b/src/Generators/BaseGenerator.php @@ -115,10 +115,10 @@ private function formattedGlobalParams(): array protected function getActualClassNameAndNamespace(?string $className, ?string $namespace): array { $parseClassName = explode('/', $className); - if (count($parseClassName) > 1) { - if (str_contains($namespace, '\Request')) { - $namespace = substr($namespace, 0, strpos($namespace, '\Request') + 8); + if (count($parseClassName) > 1) { + if (str_contains($namespace, '\Requests')) { + $namespace = substr($namespace, 0, strpos($namespace, '\Requests') + 9); } elseif (str_contains($namespace, '\Resources')) { $namespace = substr($namespace, 0, strpos($namespace, '\Resources') + 10); } diff --git a/tests/GenerateServerTest.php b/tests/GenerateServerTest.php index 71118ad..bc25a5d 100644 --- a/tests/GenerateServerTest.php +++ b/tests/GenerateServerTest.php @@ -43,7 +43,7 @@ $this->makeFilePath('/app/Http/Tests/ResourcesComponentTest.php'), $this->makeFilePath('/app/Http/Requests/TestFooRenameRequest.php'), - $this->makeFilePath('/app/Http/Request/WithDirRequests/Request.php'), + $this->makeFilePath('/app/Http/Requests/WithDirRequests/Request.php'), $this->makeFilePath('/app/Http/Requests/Foo/TestNamespaceWithDirRequest.php'), $this->makeFilePath('/app/Http/Requests/LaravelValidationsApplicationJsonRequest.php'), $this->makeFilePath('/app/Http/Requests/LaravelValidationsMultipartFormDataRequest.php'), From 20a5ca0c4c973db117ff1e010a8759d1616b05d9 Mon Sep 17 00:00:00 2001 From: imamberdiev Date: Mon, 3 Jul 2023 14:28:58 +0300 Subject: [PATCH 2/2] #108364 fix test --- tests/GenerateServerTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/GenerateServerTest.php b/tests/GenerateServerTest.php index bc25a5d..e369e41 100644 --- a/tests/GenerateServerTest.php +++ b/tests/GenerateServerTest.php @@ -161,6 +161,7 @@ assertStringContainsString( "use App\Http\Controllers\Controller11;\n". "use App\Http\Controllers\Controller2;\n". + "use App\Http\Controllers\Foo\TestController;\n" . "use App\Http\Controllers\FooItemsController;\n". "use App\Http\Controllers\FoosController;\n", $routes