Skip to content

Commit 01cbb22

Browse files
chore: small code fix
1 parent 5fbb8aa commit 01cbb22

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

src/Services/SwaggerService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ public function getConcreteRequest()
638638
$explodedController = explode('@', $controller);
639639

640640
$class = $explodedController[0];
641-
$method = $explodedController[1] ?? '__invoke';
641+
$method = Arr::get($explodedController, 1, '__invoke');
642642

643643
if (!method_exists($class, $method)) {
644644
return null;

tests/SwaggerServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ public function testAddDataWhenInvokableClass()
929929
$request = $this->generateRequest(
930930
type: 'get',
931931
uri: 'users',
932-
isInvokeController: true,
932+
controllerMethod: '__invoke',
933933
);
934934

935935
$response = $this->generateResponse('example_success_user_response.json', 200, [

tests/TestCase.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,12 @@ protected function generateRequest(
123123
$headers = [],
124124
$routeConditions = [],
125125
$controllerMethod = 'test',
126-
$isInvokeController = false,
127126
): Request {
128127
$request = $this->getBaseRequest($type, $uri, $data, $pathParams, $headers);
129128

130-
return $request->setRouteResolver(function () use ($isInvokeController, $uri, $request, $controllerMethod, $routeConditions) {
131-
$action = $isInvokeController
132-
? TestInvokableController::class . '@__invoke'
133-
: TestController::class . '@' . $controllerMethod;
134-
129+
return $request->setRouteResolver(function () use ($uri, $request, $controllerMethod, $routeConditions) {
135130
$route = Route::get($uri)
136-
->setAction(['controller' => $action])
131+
->setAction(['controller' => TestController::class . '@' . $controllerMethod])
137132
->bind($request);
138133

139134
foreach ($routeConditions as $condition) {

tests/support/Mock/TestController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ public function testRequestWithAnnotations(TestRequestWithAnnotations $request)
1919
public function testRequestWithContract(TestContract $contract, string $param)
2020
{
2121
}
22+
23+
public function __invoke(TestEmptyRequest $request)
24+
{
25+
}
2226
}

0 commit comments

Comments
 (0)