Skip to content

Commit ae1d949

Browse files
Make more nullable types explicit
1 parent 467ec97 commit ae1d949

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

Caster/ReflectionCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public static function getSignature(array $a)
368368
if (!$type instanceof \ReflectionNamedType) {
369369
$signature .= $type.' ';
370370
} else {
371-
if (!$param->isOptional() && $param->allowsNull() && 'mixed' !== $type->getName()) {
371+
if ($param->allowsNull() && 'mixed' !== $type->getName()) {
372372
$signature .= '?';
373373
}
374374
$signature .= substr(strrchr('\\'.$type->getName(), '\\'), 1).' ';

Tests/Caster/StubCasterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function testClassStub()
141141

142142
$expectedDump = <<<'EODUMP'
143143
<foo></foo><bar><span class=sf-dump-note>array:1</span> [<samp data-depth=1 class=sf-dump-expanded>
144-
<span class=sf-dump-index>0</span> => "<a href="%sFooInterface.php:10" rel="noopener noreferrer"><span class=sf-dump-str title="39 characters">hello(?stdClass $a, stdClass $b = null)</span></a>"
144+
<span class=sf-dump-index>0</span> => "<a href="%sFooInterface.php:10" rel="noopener noreferrer"><span class=sf-dump-str title="40 characters">hello(?stdClass $a, ?stdClass $b = null)</span></a>"
145145
</samp>]
146146
</bar>
147147
EODUMP;

Tests/Dumper/CliDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function testGet()
8787
+foo: ""…3
8888
+"bar": "bar"
8989
}
90-
"closure" => Closure(\$a, PDO &\$b = null) {#%d
90+
"closure" => Closure(\$a, ?PDO &\$b = null) {#%d
9191
class: "Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest"
9292
this: Symfony\Component\VarDumper\Tests\Dumper\CliDumperTest {#%d …}
9393
file: "%s%eTests%eFixtures%edumb-var.php"

Tests/Dumper/HtmlDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function testGet()
8383
+<span class=sf-dump-public title="Public property">foo</span>: "<span class=sf-dump-str title="3 characters">foo</span>"
8484
+"<span class=sf-dump-public title="Runtime added dynamic property">bar</span>": "<span class=sf-dump-str title="3 characters">bar</span>"
8585
</samp>}
86-
"<span class=sf-dump-key>closure</span>" => <span class=sf-dump-note>Closure(\$a, PDO &amp;\$b = null)</span> {<a class=sf-dump-ref>#%d</a><samp data-depth=2 class=sf-dump-compact>
86+
"<span class=sf-dump-key>closure</span>" => <span class=sf-dump-note>Closure(\$a, ?PDO &amp;\$b = null)</span> {<a class=sf-dump-ref>#%d</a><samp data-depth=2 class=sf-dump-compact>
8787
<span class=sf-dump-meta>class</span>: "<span class=sf-dump-str title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest
8888
55 characters"><span class="sf-dump-ellipsis sf-dump-ellipsis-class">Symfony\Component\VarDumper\Tests\Dumper</span><span class="sf-dump-ellipsis sf-dump-ellipsis-class">\</span>HtmlDumperTest</span>"
8989
<span class=sf-dump-meta>this</span>: <span class=sf-dump-note title="Symfony\Component\VarDumper\Tests\Dumper\HtmlDumperTest

Tests/Dumper/functions/dump_data_collector_with_spl_array.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
1414
use Symfony\Component\VarDumper\Cloner\VarCloner;
1515
use Symfony\Component\VarDumper\VarDumper;
1616

17-
VarDumper::setHandler(function ($var, string $label = null) {
17+
VarDumper::setHandler(function ($var, ?string $label = null) {
1818
$dumper = new DumpDataCollector();
1919
$cloner = new VarCloner();
20-
$handler = function ($var, string $label = null) use ($dumper, $cloner) {
20+
$handler = function ($var, ?string $label = null) use ($dumper, $cloner) {
2121
$var = $cloner->cloneVar($var);
2222
if (null !== $label) {
2323
$var = $var->withContext(['label' => $label]);

0 commit comments

Comments
 (0)