Skip to content

Commit 4560c86

Browse files
authored
Merge pull request #474 from zasan1017/fix/version3.4.0
fix: Correspondence of ReflectionException of version 3.4.0
2 parents 61dc0fb + cf5f422 commit 4560c86

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

src/Tools/Generator.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ protected function getBodyParameters(ReflectionMethod $method, array $tags)
8787
$parameterClassName = version_compare(phpversion(), '7.1.0', '<')
8888
? $paramType->__toString()
8989
: $paramType->getName();
90-
$parameterClass = new ReflectionClass($parameterClassName);
90+
91+
try {
92+
$parameterClass = new ReflectionClass($parameterClassName);
93+
} catch (\ReflectionException $e) {
94+
continue;
95+
}
96+
9197
if (class_exists('\Illuminate\Foundation\Http\FormRequest') && $parameterClass->isSubclassOf(\Illuminate\Foundation\Http\FormRequest::class)) {
9298
$formRequestDocBlock = new DocBlock($parameterClass->getDocComment());
9399
$bodyParametersFromDocBlock = $this->getBodyParametersFromDocBlock($formRequestDocBlock->getTags());

tests/Fixtures/TestController.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public function withFormRequestParameter(TestRequest $request)
5757
return '';
5858
}
5959

60+
public function withMultipleFormRequestParameters(string $test, TestRequest $request)
61+
{
62+
return '';
63+
}
64+
6065
/**
6166
* @bodyParam direct_one string Is found directly on the method.
6267
*/

tests/Unit/GeneratorTestCase.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,48 @@ public function can_parse_form_request_body_parameters()
139139
], $bodyParameters);
140140
}
141141

142+
/** @test */
143+
public function can_parse_multiple_form_request_body_parameters()
144+
{
145+
$route = $this->createRoute('GET', '/api/test', 'withMultipleFormRequestParameters');
146+
$bodyParameters = $this->generator->processRoute($route)['bodyParameters'];
147+
148+
$this->assertArraySubset([
149+
'user_id' => [
150+
'type' => 'integer',
151+
'required' => true,
152+
'description' => 'The id of the user.',
153+
'value' => 9,
154+
],
155+
'room_id' => [
156+
'type' => 'string',
157+
'required' => false,
158+
'description' => 'The id of the room.',
159+
],
160+
'forever' => [
161+
'type' => 'boolean',
162+
'required' => false,
163+
'description' => 'Whether to ban the user forever.',
164+
'value' => false,
165+
],
166+
'another_one' => [
167+
'type' => 'number',
168+
'required' => false,
169+
'description' => 'Just need something here.',
170+
],
171+
'yet_another_param' => [
172+
'type' => 'object',
173+
'required' => true,
174+
'description' => '',
175+
],
176+
'even_more_param' => [
177+
'type' => 'array',
178+
'required' => false,
179+
'description' => '',
180+
],
181+
], $bodyParameters);
182+
}
183+
142184
/** @test */
143185
public function can_parse_query_parameters()
144186
{

0 commit comments

Comments
 (0)