Skip to content

Commit 0399bf6

Browse files
committed
Fix getting parameter types from the @method annotation
1 parent 0ad57b6 commit 0399bf6

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

models/TypeDoc.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,14 @@ public function __construct($reflector = null, $context = null, $config = [])
224224
$params = [];
225225

226226
foreach ($tag->getParameters() as $parameter) {
227-
$argumentType = (string) $parameter->getType();
227+
$argumentType = $parameter->getType();
228228

229229
$params[] = new ParamDoc(null, $context, [
230230
'sourceFile' => $this->sourceFile,
231231
'name' => $parameter->getName(),
232-
'typeHint' => $argumentType,
233-
'type' => $argumentType,
234-
'types' => [$argumentType],
232+
'typeHint' => (string) $argumentType,
233+
'type' => (string) $argumentType,
234+
'types' => $this->splitTypes($argumentType),
235235
]);
236236
}
237237

tests/commands/__snapshots__/ApiControllerTest__testGenerateBootstrap__1.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ <h2>Method Details</h2>
437437

438438
<table class="detail-table table table-striped table-bordered table-hover">
439439
<tr><td colspan="3" class="signature">
440-
<span class="signature-defs">public</span> <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <strong><a href="yiiunit-apidoc-data-api-animal-animal.html#getSomething()-detail">getSomething</a></strong> ( <span style="color: #0000BB">$test</span>, <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <span style="color: #0000BB">$test2</span> )</td></tr>
440+
<span class="signature-defs">public</span> <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <strong><a href="yiiunit-apidoc-data-api-animal-animal.html#getSomething()-detail">getSomething</a></strong> ( <span style="color: #0000BB">$test</span>, <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <span style="color: #0000BB">$test2</span>, <span class="signature-type">int|string</span> <span style="color: #0000BB">$test3</span> )</td></tr>
441441

442442
<tr>
443443
<td class="param-name-col"><span style="color: #0000BB">$test</span></td>
@@ -451,6 +451,14 @@ <h2>Method Details</h2>
451451
<td class="param-desc-col">
452452
</td>
453453
</tr>
454+
<tr>
455+
<td class="param-name-col"><span style="color: #0000BB">$test3</span></td>
456+
<td class="param-type-col">
457+
<a href="https://www.php.net/language.types.integer">integer</a>|<a href="https://www.php.net/language.types.string">string</a>
458+
</td>
459+
<td class="param-desc-col">
460+
</td>
461+
</tr>
454462

455463
<tr>
456464
<th class="param-name-col">return</th>

tests/commands/__snapshots__/ApiControllerTest__testGenerateBootstrap__2.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ <h2>Method Details</h2>
323323

324324
<table class="detail-table table table-striped table-bordered table-hover">
325325
<tr><td colspan="3" class="signature">
326-
<span class="signature-defs">public</span> <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <strong><a href="yiiunit-apidoc-data-api-animal-animal.html#getSomething()-detail">getSomething</a></strong> ( <span style="color: #0000BB">$test</span>, <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <span style="color: #0000BB">$test2</span> )</td></tr>
326+
<span class="signature-defs">public</span> <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <strong><a href="yiiunit-apidoc-data-api-animal-animal.html#getSomething()-detail">getSomething</a></strong> ( <span style="color: #0000BB">$test</span>, <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <span style="color: #0000BB">$test2</span>, <span class="signature-type">int|string</span> <span style="color: #0000BB">$test3</span> )</td></tr>
327327

328328
<tr>
329329
<td class="param-name-col"><span style="color: #0000BB">$test</span></td>
@@ -337,6 +337,14 @@ <h2>Method Details</h2>
337337
<td class="param-desc-col">
338338
</td>
339339
</tr>
340+
<tr>
341+
<td class="param-name-col"><span style="color: #0000BB">$test3</span></td>
342+
<td class="param-type-col">
343+
<a href="https://www.php.net/language.types.integer">integer</a>|<a href="https://www.php.net/language.types.string">string</a>
344+
</td>
345+
<td class="param-desc-col">
346+
</td>
347+
</tr>
340348

341349
<tr>
342350
<th class="param-name-col">return</th>

tests/commands/__snapshots__/ApiControllerTest__testGenerateBootstrap__3.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ <h2>Method Details</h2>
318318

319319
<table class="detail-table table table-striped table-bordered table-hover">
320320
<tr><td colspan="3" class="signature">
321-
<span class="signature-defs">public</span> <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <strong><a href="yiiunit-apidoc-data-api-animal-animal.html#getSomething()-detail">getSomething</a></strong> ( <span style="color: #0000BB">$test</span>, <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <span style="color: #0000BB">$test2</span> )</td></tr>
321+
<span class="signature-defs">public</span> <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <strong><a href="yiiunit-apidoc-data-api-animal-animal.html#getSomething()-detail">getSomething</a></strong> ( <span style="color: #0000BB">$test</span>, <span class="signature-type"><a href="https://www.php.net/language.types.integer">integer</a></span> <span style="color: #0000BB">$test2</span>, <span class="signature-type">int|string</span> <span style="color: #0000BB">$test3</span> )</td></tr>
322322

323323
<tr>
324324
<td class="param-name-col"><span style="color: #0000BB">$test</span></td>
@@ -332,6 +332,14 @@ <h2>Method Details</h2>
332332
<td class="param-desc-col">
333333
</td>
334334
</tr>
335+
<tr>
336+
<td class="param-name-col"><span style="color: #0000BB">$test3</span></td>
337+
<td class="param-type-col">
338+
<a href="https://www.php.net/language.types.integer">integer</a>|<a href="https://www.php.net/language.types.string">string</a>
339+
</td>
340+
<td class="param-desc-col">
341+
</td>
342+
</tr>
335343

336344
<tr>
337345
<th class="param-name-col">return</th>

tests/data/api/animal/Animal.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
* @property int $age animal age in seconds.
1616
*
17-
* @method int getSomething($test, int $test2)
17+
* @method int getSomething($test, int $test2, int|string $test3)
1818
*
1919
* @author Paul Klimov <[email protected]>
2020
* @since 1.0

0 commit comments

Comments
 (0)