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']);
|
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);
|
$normalizedType = key($typesMap);
|
||||||
$returnType = current($typesMap);
|
$returnType = current($typesMap);
|
||||||
|
|
||||||
@ -762,8 +770,14 @@ class DebugClassLoader
|
|||||||
$normalizedType = $t;
|
$normalizedType = $t;
|
||||||
$returnType = $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)) {
|
} 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)) {
|
||||||
// ignore multi-types return declarations
|
if ($iterable) {
|
||||||
return;
|
$normalizedType = $returnType = 'iterable';
|
||||||
|
} elseif ($object) {
|
||||||
|
$normalizedType = $returnType = 'object';
|
||||||
|
} else {
|
||||||
|
// ignore multi-types return declarations
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,10 @@ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage\Handler;
|
|||||||
|
|
||||||
class RedisArraySessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
class RedisArraySessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
||||||
{
|
{
|
||||||
protected function createRedisClient(string $host): \RedisArray
|
/**
|
||||||
|
* @return \RedisArray|object
|
||||||
|
*/
|
||||||
|
protected function createRedisClient(string $host)
|
||||||
{
|
{
|
||||||
return new \RedisArray([$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')));
|
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
|
class RedisSessionHandlerTest extends AbstractRedisSessionHandlerTestCase
|
||||||
{
|
{
|
||||||
protected function createRedisClient(string $host): \Redis
|
/**
|
||||||
|
* @return \Redis|object
|
||||||
|
*/
|
||||||
|
protected function createRedisClient(string $host)
|
||||||
{
|
{
|
||||||
$client = new \Redis();
|
$client = new \Redis();
|
||||||
$client->connect($host);
|
$client->connect($host);
|
||||||
|
Reference in New Issue
Block a user