Skip to content

Commit

Permalink
Merge branch '6.1' into 6.2
Browse files Browse the repository at this point in the history
* 6.1:
  [Mailer] Include all transports' debug messages in RoundRobin transport exception
  [FrameworkBundle] fix: fix help message
  Fix HtmlSanitizer default configuration behavior for allowed schemes
  Use relative timestamps
  [Cache] Fix dealing with ext-redis' multi/exec returning a bool
  [Messenger][Amqp] Added missing rpc_timeout option
  [Serializer] Prevent GetSetMethodNormalizer from creating invalid magic method call
  [HttpFoundation] Fix dumping array cookies
  [WebProfilerBundle] Fix dump header not being displayed
  TraceableHttpClient: increase decorator's priority
  Use static methods inside data providers
  [FrameworkBundle] Allow configuring `framework.exceptions` with a config builder
  bug #48313 [Mime] Fix MessagePart serialization
  [HttpKernel][ErrorHandler] Fix reading the SYMFONY_IDE env var
  [ErrorHandler][DebugClassLoader] Fix some new return types support
  Fix getting the name of closures on PHP 8.1.11+
  [Translator] Fix typo "internal" / "interval"
  fix dumping top-level tagged values
  [Console] Fix clear line with question in section
  • Loading branch information
nicolas-grekas committed Dec 14, 2022
2 parents b4e41f6 + 6e1416f commit 12a25d0
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 2 deletions.
12 changes: 11 additions & 1 deletion DebugClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class DebugClassLoader
'null' => 'null',
'resource' => 'resource',
'boolean' => 'bool',
'true' => 'bool',
'true' => 'true',
'false' => 'false',
'integer' => 'int',
'array' => 'array',
Expand All @@ -75,6 +75,7 @@ class DebugClassLoader
'$this' => 'static',
'list' => 'array',
'class-string' => 'string',
'never' => 'never',
];

private const BUILTIN_RETURN_TYPES = [
Expand All @@ -92,6 +93,9 @@ class DebugClassLoader
'parent' => true,
'mixed' => true,
'static' => true,
'null' => true,
'true' => true,
'never' => true,
];

private const MAGIC_METHODS = [
Expand Down Expand Up @@ -796,6 +800,12 @@ private function setReturnType(string $types, string $class, string $method, str
return;
}

if ('null' === $types) {
self::$returnTypes[$class][$method] = ['null', 'null', $class, $filename];

return;
}

if ($nullable = str_starts_with($types, 'null|')) {
$types = substr($types, 5);
} elseif ($nullable = str_ends_with($types, '|null')) {
Expand Down
2 changes: 1 addition & 1 deletion ErrorRenderer/HtmlErrorRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(bool|callable $debug = false, string $charset = null
{
$this->debug = \is_bool($debug) ? $debug : $debug(...);
$this->charset = $charset ?: (\ini_get('default_charset') ?: 'UTF-8');
$fileLinkFormat ??= $_SERVER['SYMFONY_IDE'] ?? null;
$fileLinkFormat ??= $_ENV['SYMFONY_IDE'] ?? $_SERVER['SYMFONY_IDE'] ?? null;
$this->fileLinkFormat = \is_string($fileLinkFormat)
? (ErrorRendererInterface::IDE_LINK_FORMATS[$fileLinkFormat] ?? $fileLinkFormat ?: false)
: ($fileLinkFormat ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: false);
Expand Down
1 change: 1 addition & 0 deletions Internal/TentativeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@ class TentativeTypes
'isVariadic' => 'bool',
'isStatic' => 'bool',
'getClosureThis' => '?object',
'getClosureCalledClass' => '?ReflectionClass',
'getClosureScopeClass' => '?ReflectionClass',
'getDocComment' => 'string|false',
'getEndLine' => 'int|false',
Expand Down
4 changes: 4 additions & 0 deletions Tests/DebugClassLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ class_exists('Test\\'.ReturnType::class, true);
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::mixed()" might add "mixed" as a native return type declaration in the future. Do the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" now to avoid errors or add an explicit @return annotation to suppress this message.',
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::nullableMixed()" might add "mixed" as a native return type declaration in the future. Do the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" now to avoid errors or add an explicit @return annotation to suppress this message.',
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::static()" might add "static" as a native return type declaration in the future. Do the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" now to avoid errors or add an explicit @return annotation to suppress this message.',
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::false()" might add "false" as a native return type declaration in the future. Do the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" now to avoid errors or add an explicit @return annotation to suppress this message.',
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::true()" might add "true" as a native return type declaration in the future. Do the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" now to avoid errors or add an explicit @return annotation to suppress this message.',
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::never()" might add "never" as a native return type declaration in the future. Do the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" now to avoid errors or add an explicit @return annotation to suppress this message.',
'Method "Symfony\Component\ErrorHandler\Tests\Fixtures\ReturnTypeParent::null()" might add "null" as a native return type declaration in the future. Do the same in child class "Test\Symfony\Component\ErrorHandler\Tests\ReturnType" now to avoid errors or add an explicit @return annotation to suppress this message.',
], $deprecations);
}

Expand Down
4 changes: 4 additions & 0 deletions Tests/Fixtures/ReturnType.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ public function this() { }
public function mixed() { }
public function nullableMixed() { }
public function static() { }
public function false() { }
public function true() { }
public function never() { }
public function null() { }
public function outsideMethod() { }
}
28 changes: 28 additions & 0 deletions Tests/Fixtures/ReturnTypeParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,34 @@ public function static()
{
}

/**
* @return false
*/
public function false()
{
}

/**
* @return true
*/
public function true()
{
}

/**
* @return never
*/
public function never()
{
}

/**
* @return null
*/
public function null()
{
}

/**
* @return int
*/
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
>
<php>
<ini name="error_reporting" value="-1" />
<env name="SYMFONY_IDE" value="" force="true" />
</php>

<testsuites>
Expand Down

0 comments on commit 12a25d0

Please sign in to comment.