Skip to content

Commit dc4af45

Browse files
authored
Merge branch 'master' into update-gitattributes
2 parents 0b3b781 + e70d096 commit dc4af45

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Yii Framework 2 apidoc extension Change Log
1111
- Bug #339: Fix the mechanism for replacing `static` with FQCN (mspirkov)
1212
- Bug #339: Fix processing of multidimensional arrays (mspirkov)
1313
- Enh #342: Remove unnecessary files from Composer package (mspirkov)
14+
- Enh #341: Add support for nullable types (mspirkov)
1415

1516

1617
3.0.8 November 24, 2025

renderers/BaseRenderer.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
use phpDocumentor\Reflection\Types\InterfaceString;
3131
use phpDocumentor\Reflection\Types\Intersection;
3232
use phpDocumentor\Reflection\Types\Iterable_;
33+
use phpDocumentor\Reflection\Types\Null_;
34+
use phpDocumentor\Reflection\Types\Nullable;
3335
use phpDocumentor\Reflection\Types\Object_;
3436
use phpDocumentor\Reflection\Types\Self_;
3537
use phpDocumentor\Reflection\Types\Static_;
@@ -291,6 +293,11 @@ public function createTypeLink(
291293
continue;
292294
}
293295

296+
if ($type instanceof Nullable) {
297+
$links[] = $this->createTypeLink([$type->getActualType(), new Null_()]);
298+
continue;
299+
}
300+
294301
if (($link = $this->createLinkByTypeWithGenerics($type, $context, $title, $options, $currentTypeDoc)) !== null) {
295302
$links[] = $link;
296303
continue;

tests/commands/__snapshots__/ApiControllerTest__testGenerateBootstrap__3.html

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,11 @@ <h2>Public Methods</h2>
377377
<td><a href="yiiunit-apidoc-data-api-animal-dog.html#getNonEmptyListWithoutGenerics()-detail">getNonEmptyListWithoutGenerics()</a></td>
378378
<td></td>
379379
<td><a href="yiiunit-apidoc-data-api-animal-dog.html">yiiunit\apidoc\data\api\animal\Dog</a></td>
380+
</tr>
381+
<tr class="">
382+
<td><a href="yiiunit-apidoc-data-api-animal-dog.html#getNullableString()-detail">getNullableString()</a></td>
383+
<td>Some description</td>
384+
<td><a href="yiiunit-apidoc-data-api-animal-dog.html">yiiunit\apidoc\data\api\animal\Dog</a></td>
380385
</tr>
381386
<tr class="">
382387
<td><a href="yiiunit-apidoc-data-api-animal-dog.html#getObjectShapeWithStaticGeneric()-detail">getObjectShapeWithStaticGeneric()</a></td>
@@ -1102,6 +1107,51 @@ <h2>Method Details</h2>
11021107
</span>{
11031108
<span class="hljs-keyword">return</span> [];
11041109
}
1110+
</code>
1111+
</pre>
1112+
</div>
1113+
</div>
1114+
1115+
</div>
1116+
<div class="">
1117+
<div class="detail-header h3">
1118+
<a class="tool-link" title="go to top"><span class="glyphicon glyphicon-arrow-up"></span></a>
1119+
<a class="tool-link hash" href="yiiunit-apidoc-data-api-animal-dog.html#getNullableString()-detail" title="direct link to this method"><span class="glyphicon icon-hash"></span></a>
1120+
1121+
getNullableString()
1122+
1123+
<span class="detail-header-tag small">
1124+
public method
1125+
</span>
1126+
</div>
1127+
1128+
1129+
<div class="doc-description">
1130+
1131+
<p><strong>Some description</strong></p>
1132+
</div>
1133+
1134+
<table class="detail-table table table-striped table-bordered table-hover">
1135+
<tr><td colspan="3" class="signature">
1136+
<span class="signature-defs">public</span><span class="signature-type"><a href="https://www.php.net/language.types.string">string</a>|<a href="https://www.php.net/language.types.null">null</a></span><strong><a href="yiiunit-apidoc-data-api-animal-dog.html#getNullableString()-detail">getNullableString</a></strong> ( )</td></tr>
1137+
1138+
</table>
1139+
1140+
1141+
1142+
1143+
<p>
1144+
<a class="btn btn-link" data-toggle="collapse" role="button" aria-expanded="false" aria-controls="collapseGetNullableString">
1145+
Source code
1146+
</a>
1147+
</p>
1148+
<div class="collapse">
1149+
<div class="card card-body">
1150+
<pre>
1151+
<code class="hljs php language-php"><span class="hljs-keyword">public</span><span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-title">getNullableString</span><span class="hljs-params">()</span>: ?<span class="hljs-title">string</span>
1152+
</span>{
1153+
<span class="hljs-keyword">return</span><span class="hljs-keyword">null</span>;
1154+
}
11051155
</code>
11061156
</pre>
11071157
</div>

tests/data/api/animal/Dog.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,12 @@ public function getObjectShapeWithStaticGeneric()
123123
public function getStaticOrNull()
124124
{
125125
}
126+
127+
/**
128+
* Some description
129+
*/
130+
public function getNullableString(): ?string
131+
{
132+
return null;
133+
}
126134
}

0 commit comments

Comments
 (0)