Skip to content

Commit c67db13

Browse files
[VarExporter] Dump implicit-nullable types as explicit to prevent the corresponding deprecation
1 parent 1299446 commit c67db13

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

.php-cs-fixer.dist.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
'allow_unused_params' => true, // for future-ready params, to be replaced with https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7377
3737
],
3838
'header_comment' => ['header' => $fileHeaderComment],
39-
// TODO: Remove once the "compiler_optimized" set includes "sprintf"
40-
'native_function_invocation' => ['include' => ['@compiler_optimized', 'sprintf'], 'scope' => 'namespaced', 'strict' => true],
4139
'nullable_type_declaration' => true,
4240
'nullable_type_declaration_for_default_null_value' => true,
4341
'modernize_strpos' => true,

src/Symfony/Component/VarExporter/ProxyHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,9 @@ public static function exportType(\ReflectionFunctionAbstract|\ReflectionPropert
477477
return '';
478478
}
479479
if (null === $glue) {
480-
return (!$noBuiltin && $type->allowsNull() && !\in_array($name, ['mixed', 'null'], true) ? '?' : '').$types[0];
480+
$defaultNull = $owner instanceof \ReflectionParameter && 'null' === rtrim(substr(explode('$'.$owner->name.' = ', (string) $owner, 2)[1] ?? '', 0, -2));
481+
482+
return (!$noBuiltin && ($type->allowsNull() || $defaultNull) && !\in_array($name, ['mixed', 'null'], true) ? '?' : '').$types[0];
481483
}
482484
sort($types);
483485

0 commit comments

Comments
 (0)