Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6fd1794

Browse filesBrowse files
committed
[VarExporter] fix proxy helper when a method returns null
1 parent 202199b commit 6fd1794
Copy full SHA for 6fd1794

File tree

Expand file treeCollapse file tree

2 files changed

+19
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-1
lines changed

‎src/Symfony/Component/VarExporter/ProxyHelper.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarExporter/ProxyHelper.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public static function exportType(\ReflectionFunctionAbstract|\ReflectionPropert
311311
return '';
312312
}
313313
if (null === $glue) {
314-
return (!$noBuiltin && $type->allowsNull() && 'mixed' !== $name ? '?' : '').$types[0];
314+
return (!$noBuiltin && $type->allowsNull() && $type->getName() !== 'null' && 'mixed' !== $name ? '?' : '').$types[0];
315315
}
316316
sort($types);
317317

‎src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarExporter/Tests/ProxyHelperTest.php
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,24 @@ public function testCannotGenerateGhostForStringMagicGet()
188188
$this->expectException(LogicException::class);
189189
ProxyHelper::generateLazyGhost(new \ReflectionClass(StringMagicGetClass::class));
190190
}
191+
192+
/**
193+
* @requires PHP 8.2
194+
*/
195+
public function testNullStandaloneReturnType()
196+
{
197+
$classWithNullReturnType = new class{
198+
public function foo(): null
199+
{
200+
return null;
201+
}
202+
};
203+
204+
self::assertStringContainsString(
205+
'public function foo(): null',
206+
ProxyHelper::generateLazyProxy(new \ReflectionClass($classWithNullReturnType))
207+
);
208+
}
191209
}
192210

193211
abstract class TestForProxyHelper

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.