Merge branch '4.4'
* 4.4: [ErrorHandler] make DebugClassLoader turn multi-types declarations to "object"
This commit is contained in:
commit
7d451144bf
@ -752,6 +752,14 @@ class DebugClassLoader
|
||||
unset($typesMap['array']);
|
||||
}
|
||||
|
||||
$iterable = $object = true;
|
||||
foreach ($typesMap as $n => $t) {
|
||||
if ('null' !== $n) {
|
||||
$iterable = $iterable && (\in_array($n, ['array', 'iterable']) || false !== strpos($n, 'Iterator'));
|
||||
$object = $object && (\in_array($n, ['callable', 'object', '$this', 'static']) || !isset(self::SPECIAL_RETURN_TYPES[$n]));
|
||||
}
|
||||
}
|
||||
|
||||
$normalizedType = key($typesMap);
|
||||
$returnType = current($typesMap);
|
||||
|
||||
@ -762,10 +770,16 @@ class DebugClassLoader
|
||||
$normalizedType = $t;
|
||||
$returnType = $t;
|
||||
} elseif ($n !== $normalizedType || !preg_match('/^\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+(?:\\\\[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+)*+$/', $n)) {
|
||||
if ($iterable) {
|
||||
$normalizedType = $returnType = 'iterable';
|
||||
} elseif ($object) {
|
||||
$normalizedType = $returnType = 'object';
|
||||
} else {
|
||||
// ignore multi-types return declarations
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ('void' === $normalizedType) {
|
||||
$nullable = false;
|
||||
|
@ -13,7 +13,10 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
||||
|
||||
class RedisArraySessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
||||
{
|
||||
protected function createRedisClient(string $host): \RedisArray
|
||||
/**
|
||||
* @return \RedisArray|object
|
||||
*/
|
||||
protected function createRedisClient(string $host)
|
||||
{
|
||||
return new \RedisArray([$host]);
|
||||
}
|
||||
|
@ -24,7 +24,10 @@ class RedisClusterSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
||||
}
|
||||
}
|
||||
|
||||
protected function createRedisClient(string $host): \RedisCluster
|
||||
/**
|
||||
* @return \RedisCluster|object
|
||||
*/
|
||||
protected function createRedisClient(string $host)
|
||||
{
|
||||
return new \RedisCluster(null, explode(' ', getenv('REDIS_CLUSTER_HOSTS')));
|
||||
}
|
||||
|
@ -13,7 +13,10 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
||||
|
||||
class RedisSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
||||
{
|
||||
protected function createRedisClient(string $host): \Redis
|
||||
/**
|
||||
* @return \Redis|object
|
||||
*/
|
||||
protected function createRedisClient(string $host)
|
||||
{
|
||||
$client = new \Redis();
|
||||
$client->connect($host);
|
||||
|
Reference in New Issue
Block a user