Merge branch '4.3' into 4.4

* 4.3:
  [FrameworkBundle] Detect indirect env vars in routing
  Remove calls to deprecated function assertAttributeX
  [Intl] Order alpha2 to alpha3 mapping
  [Routing] added a warning about the getRouteCollection() method
  Allow sutFqcnResolver to return array
  [HttpFoundation] Revert getClientIp @return docblock
This commit is contained in:
Fabien Potencier 2019-08-05 07:50:38 +02:00
commit 94f588a706
10 changed files with 84 additions and 58 deletions

View File

@ -76,7 +76,7 @@ class CoverageListenerTrait
$cache = $r->getValue();
$cache = array_replace_recursive($cache, array(
\get_class($test) => array(
'covers' => array($sutFqcn),
'covers' => \is_array($sutFqcn) ? $sutFqcn : array($sutFqcn),
),
));
$r->setValue($testClass, $cache);

View File

@ -160,7 +160,7 @@ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberI
return '%%';
}
if (preg_match('/^env\(\w+\)$/', $match[1])) {
if (preg_match('/^env\((?:\w++:)*+\w++\)$/', $match[1])) {
throw new RuntimeException(sprintf('Using "%%%s%%" is not allowed in routing configuration.', $match[1]));
}
@ -173,7 +173,7 @@ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberI
if (\is_string($resolved) || is_numeric($resolved)) {
$this->collectedParameters[$match[1]] = $resolved;
return (string) $resolved;
return (string) $this->resolve($resolved);
}
throw new RuntimeException(sprintf('The container parameter "%s", used in the route configuration value "%s", must be a string or numeric, but it is of type %s.', $match[1], $value, \gettype($resolved)));

View File

@ -16,6 +16,7 @@ use Psr\Container\ContainerInterface;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
@ -278,13 +279,13 @@ class RouterTest extends TestCase
$routes->add('foo', new Route('/before/%parameter.foo%/after/%%escaped%%'));
$sc = $this->getServiceContainer($routes);
$sc->setParameter('parameter.foo', 'foo');
$sc->setParameter('parameter.foo', 'foo-%%escaped%%');
$router = new Router($sc, 'foo');
$route = $router->getRouteCollection()->get('foo');
$this->assertEquals(
'/before/foo/after/%escaped%',
'/before/foo-%escaped%/after/%escaped%',
$route->getPath()
);
}
@ -313,6 +314,22 @@ class RouterTest extends TestCase
$router->getRouteCollection();
}
public function testIndirectEnvPlaceholders()
{
$routes = new RouteCollection();
$routes->add('foo', new Route('/%foo%'));
$router = new Router($container = $this->getServiceContainer($routes), 'foo');
$container->setParameter('foo', 'foo-%bar%');
$container->setParameter('bar', '%env(string:FOO)%');
$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Using "%env(string:FOO)%" is not allowed in routing configuration.');
$router->getRouteCollection();
}
public function testHostPlaceholders()
{
$routes = new RouteCollection();

View File

@ -61,14 +61,14 @@ class GenericEventTest extends TestCase
public function testSetArguments()
{
$result = $this->event->setArguments(['foo' => 'bar']);
$this->assertAttributeSame(['foo' => 'bar'], 'arguments', $this->event);
$this->assertSame(['foo' => 'bar'], $this->event->getArguments());
$this->assertSame($this->event, $result);
}
public function testSetArgument()
{
$result = $this->event->setArgument('foo2', 'bar2');
$this->assertAttributeSame(['name' => 'Event', 'foo2' => 'bar2'], 'arguments', $this->event);
$this->assertSame(['name' => 'Event', 'foo2' => 'bar2'], $this->event->getArguments());
$this->assertEquals($this->event, $result);
}
@ -97,13 +97,13 @@ class GenericEventTest extends TestCase
public function testOffsetSet()
{
$this->event['foo2'] = 'bar2';
$this->assertAttributeSame(['name' => 'Event', 'foo2' => 'bar2'], 'arguments', $this->event);
$this->assertSame(['name' => 'Event', 'foo2' => 'bar2'], $this->event->getArguments());
}
public function testOffsetUnset()
{
unset($this->event['name']);
$this->assertAttributeSame([], 'arguments', $this->event);
$this->assertSame([], $this->event->getArguments());
}
public function testOffsetIsset()

View File

@ -796,7 +796,11 @@ class Request
* being the original client, and each successive proxy that passed the request
* adding the IP address where it received the request from.
*
* @return string|null The client IP address
* If your reverse proxy uses a different header name than "X-Forwarded-For",
* ("Client-Ip" for instance), configure it via the $trustedHeaderSet
* argument of the Request::setTrustedProxies() method instead.
*
* @return string The client IP address
*
* @see getClientIps()
* @see http://en.wikipedia.org/wiki/X-Forwarded-For

View File

@ -317,15 +317,15 @@ class PdoSessionHandlerTest extends TestCase
public function testUrlDsn($url, $expectedDsn, $expectedUser = null, $expectedPassword = null)
{
$storage = new PdoSessionHandler($url);
$reflection = new \ReflectionClass(PdoSessionHandler::class);
$this->assertAttributeEquals($expectedDsn, 'dsn', $storage);
if (null !== $expectedUser) {
$this->assertAttributeEquals($expectedUser, 'username', $storage);
}
if (null !== $expectedPassword) {
$this->assertAttributeEquals($expectedPassword, 'password', $storage);
foreach (['dsn' => $expectedDsn, 'username' => $expectedUser, 'password' => $expectedPassword] as $property => $expectedValue) {
if (!isset($expectedValue)) {
continue;
}
$property = $reflection->getProperty($property);
$property->setAccessible(true);
$this->assertSame($expectedValue, $property->getValue($storage));
}
}

View File

@ -205,6 +205,8 @@ class LanguageDataGenerator extends AbstractDataGenerator
}
}
asort($alpha2ToAlpha3);
return $alpha2ToAlpha3;
}
}

View File

@ -622,14 +622,11 @@
"Alpha2ToAlpha3": {
"aa": "aar",
"ab": "abk",
"dz": "dzo",
"af": "afr",
"ak": "aka",
"sq": "sqi",
"am": "amh",
"ar": "ara",
"an": "arg",
"hy": "hye",
"as": "asm",
"av": "ava",
"ae": "ave",
@ -637,7 +634,6 @@
"az": "aze",
"ba": "bak",
"bm": "bam",
"eu": "eus",
"be": "bel",
"bn": "ben",
"bi": "bis",
@ -645,12 +641,10 @@
"bs": "bos",
"br": "bre",
"bg": "bul",
"my": "mya",
"ca": "cat",
"cs": "ces",
"ch": "cha",
"ce": "che",
"zh": "zho",
"cu": "chu",
"cv": "chv",
"kw": "cor",
@ -660,13 +654,12 @@
"da": "dan",
"de": "deu",
"dv": "div",
"mn": "mon",
"nl": "nld",
"et": "est",
"dz": "dzo",
"el": "ell",
"en": "eng",
"eo": "epo",
"ik": "ipk",
"et": "est",
"eu": "eus",
"ee": "ewe",
"fo": "fao",
"fa": "fas",
@ -675,8 +668,6 @@
"fr": "fra",
"fy": "fry",
"ff": "ful",
"om": "orm",
"ka": "kat",
"gd": "gla",
"ga": "gle",
"gl": "glg",
@ -691,31 +682,34 @@
"ho": "hmo",
"hr": "hrv",
"hu": "hun",
"hy": "hye",
"ig": "ibo",
"is": "isl",
"io": "ido",
"ii": "iii",
"iu": "iku",
"ie": "ile",
"ia": "ina",
"id": "ind",
"ik": "ipk",
"is": "isl",
"it": "ita",
"jv": "jav",
"ja": "jpn",
"kl": "kal",
"kn": "kan",
"ks": "kas",
"ka": "kat",
"kr": "kau",
"kk": "kaz",
"km": "khm",
"ki": "kik",
"rw": "kin",
"ky": "kir",
"ku": "kur",
"kg": "kon",
"kv": "kom",
"kg": "kon",
"ko": "kor",
"kj": "kua",
"ku": "kur",
"lo": "lao",
"la": "lat",
"lv": "lav",
@ -725,40 +719,43 @@
"lb": "ltz",
"lu": "lub",
"lg": "lug",
"mk": "mkd",
"mh": "mah",
"ml": "mal",
"mi": "mri",
"mr": "mar",
"ms": "msa",
"mk": "mkd",
"mg": "mlg",
"mt": "mlt",
"ro": "ron",
"mn": "mon",
"mi": "mri",
"ms": "msa",
"my": "mya",
"na": "nau",
"nv": "nav",
"nr": "nbl",
"nd": "nde",
"ng": "ndo",
"ne": "nep",
"nl": "nld",
"nn": "nno",
"nb": "nob",
"ny": "nya",
"oc": "oci",
"oj": "oji",
"or": "ori",
"om": "orm",
"os": "oss",
"pa": "pan",
"ps": "pus",
"pi": "pli",
"pl": "pol",
"pt": "por",
"ps": "pus",
"qu": "que",
"rm": "roh",
"ro": "ron",
"rn": "run",
"ru": "rus",
"sg": "sag",
"sa": "san",
"sr": "srp",
"si": "sin",
"sk": "slk",
"sl": "slv",
@ -769,7 +766,9 @@
"so": "som",
"st": "sot",
"es": "spa",
"sq": "sqi",
"sc": "srd",
"sr": "srp",
"ss": "ssw",
"su": "sun",
"sw": "swa",
@ -799,6 +798,7 @@
"yi": "yid",
"yo": "yor",
"za": "zha",
"zh": "zho",
"zu": "zul"
}
}

View File

@ -647,11 +647,9 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
'ab' => 'abk',
'af' => 'afr',
'ak' => 'aka',
'sq' => 'sqi',
'am' => 'amh',
'ar' => 'ara',
'an' => 'arg',
'hy' => 'hye',
'as' => 'asm',
'av' => 'ava',
'ae' => 'ave',
@ -659,7 +657,6 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
'az' => 'aze',
'ba' => 'bak',
'bm' => 'bam',
'eu' => 'eus',
'be' => 'bel',
'bn' => 'ben',
'bi' => 'bis',
@ -667,12 +664,10 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
'bs' => 'bos',
'br' => 'bre',
'bg' => 'bul',
'my' => 'mya',
'ca' => 'cat',
'cs' => 'ces',
'ch' => 'cha',
'ce' => 'che',
'zh' => 'zho',
'cu' => 'chu',
'cv' => 'chv',
'kw' => 'cor',
@ -682,13 +677,12 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
'da' => 'dan',
'de' => 'deu',
'dv' => 'div',
'nl' => 'nld',
'dz' => 'dzo',
'et' => 'est',
'el' => 'ell',
'en' => 'eng',
'eo' => 'epo',
'ik' => 'ipk',
'et' => 'est',
'eu' => 'eus',
'ee' => 'ewe',
'fo' => 'fao',
'fa' => 'fas',
@ -697,8 +691,6 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
'fr' => 'fra',
'fy' => 'fry',
'ff' => 'ful',
'om' => 'orm',
'ka' => 'kat',
'gd' => 'gla',
'ga' => 'gle',
'gl' => 'glg',
@ -713,32 +705,34 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
'ho' => 'hmo',
'hr' => 'hrv',
'hu' => 'hun',
'hy' => 'hye',
'ig' => 'ibo',
'is' => 'isl',
'io' => 'ido',
'ii' => 'iii',
'iu' => 'iku',
'ie' => 'ile',
'ia' => 'ina',
'id' => 'ind',
'ik' => 'ipk',
'is' => 'isl',
'it' => 'ita',
'jv' => 'jav',
'ja' => 'jpn',
'kl' => 'kal',
'kn' => 'kan',
'ks' => 'kas',
'ka' => 'kat',
'kr' => 'kau',
'kk' => 'kaz',
'mn' => 'mon',
'km' => 'khm',
'ki' => 'kik',
'rw' => 'kin',
'ky' => 'kir',
'ku' => 'kur',
'kg' => 'kon',
'kv' => 'kom',
'kg' => 'kon',
'ko' => 'kor',
'kj' => 'kua',
'ku' => 'kur',
'lo' => 'lao',
'la' => 'lat',
'lv' => 'lav',
@ -748,32 +742,36 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
'lb' => 'ltz',
'lu' => 'lub',
'lg' => 'lug',
'mk' => 'mkd',
'mh' => 'mah',
'ml' => 'mal',
'mi' => 'mri',
'mr' => 'mar',
'ms' => 'msa',
'mk' => 'mkd',
'mg' => 'mlg',
'mt' => 'mlt',
'mn' => 'mon',
'mi' => 'mri',
'ms' => 'msa',
'my' => 'mya',
'na' => 'nau',
'nv' => 'nav',
'nr' => 'nbl',
'nd' => 'nde',
'ng' => 'ndo',
'ne' => 'nep',
'nl' => 'nld',
'nn' => 'nno',
'nb' => 'nob',
'ny' => 'nya',
'oc' => 'oci',
'oj' => 'oji',
'or' => 'ori',
'om' => 'orm',
'os' => 'oss',
'pa' => 'pan',
'ps' => 'pus',
'pi' => 'pli',
'pl' => 'pol',
'pt' => 'por',
'ps' => 'pus',
'qu' => 'que',
'rm' => 'roh',
'ro' => 'ron',
@ -781,7 +779,6 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
'ru' => 'rus',
'sg' => 'sag',
'sa' => 'san',
'sr' => 'srp',
'si' => 'sin',
'sk' => 'slk',
'sl' => 'slv',
@ -792,7 +789,9 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
'so' => 'som',
'st' => 'sot',
'es' => 'spa',
'sq' => 'sqi',
'sc' => 'srd',
'sr' => 'srp',
'ss' => 'ssw',
'su' => 'sun',
'sw' => 'swa',
@ -822,6 +821,7 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
'yi' => 'yid',
'yo' => 'yor',
'za' => 'zha',
'zh' => 'zho',
'zu' => 'zul',
];

View File

@ -26,6 +26,9 @@ interface RouterInterface extends UrlMatcherInterface, UrlGeneratorInterface
/**
* Gets the RouteCollection instance associated with this Router.
*
* WARNING: This method should never be used at runtime as it is SLOW.
* You might use it in a cache warmer though.
*
* @return RouteCollection A RouteCollection instance
*/
public function getRouteCollection();