Merge branch '4.4'

* 4.4:
  [Mailer] Fix SmtpEnvelope renaming to Envelope
  fixed "link" to Contracts packages
  [WebProfilerBundle] Fix time panel legend buttons
  Some styling tweaks
  Fixed cache pools affecting each other due to an overwritten seed variable
  don't change state in case of exception
  properly catch legacy tag syntax usages
  minor tweaks to the welcome page
This commit is contained in:
Christian Flothmann 2019-09-16 07:06:55 +02:00
commit 0354395ee9
10 changed files with 87 additions and 31 deletions

2
link
View File

@ -35,7 +35,7 @@ if (!is_dir("$pathToProject/vendor/symfony")) {
$sfPackages = array('symfony/symfony' => __DIR__);
$filesystem = new Filesystem();
$braces = array('Bundle', 'Bridge', 'Component', 'Component/Security');
$braces = array('Bundle', 'Bridge', 'Component', 'Component/Security', 'Contracts');
$directories = array_merge(...array_values(array_map(function ($part) {
return glob(__DIR__.'/src/Symfony/'.$part.'/*', GLOB_ONLYDIR | GLOB_NOSORT);
}, $braces)));

View File

@ -222,7 +222,8 @@ class Legend {
this.toggle = this.toggle.bind(this);
this.createCategory = this.createCategory.bind(this);
this.categories = Array.from(this.theme.getDefaultCategories()).map(this.createCategory);
this.categories = [];
this.theme.getDefaultCategories().forEach(this.createCategory)
}
add(category) {
@ -240,6 +241,8 @@ class Legend {
this.element.appendChild(element);
this.categories.push(element);
return element;
}

View File

@ -79,11 +79,12 @@ class CachePoolPass implements CompilerPassInterface
}
$name = $tags[0]['name'] ?? $id;
if (!isset($tags[0]['namespace'])) {
$namespaceSeed = $seed;
if (null !== $class) {
$seed .= '.'.$class;
$namespaceSeed .= '.'.$class;
}
$tags[0]['namespace'] = $this->getNamespace($seed, $name);
$tags[0]['namespace'] = $this->getNamespace($namespaceSeed, $name);
}
if (isset($tags[0]['clearer'])) {
$clearer = $tags[0]['clearer'];

View File

@ -70,6 +70,33 @@ class CachePoolPassTest extends TestCase
$this->assertSame('xmOJ8gqF-Y', $cachePool->getArgument(0));
}
public function testNamespaceArgumentIsSeededWithAdapterClassNameWithoutAffectingOtherCachePools()
{
$container = new ContainerBuilder();
$container->setParameter('kernel.container_class', 'app');
$container->setParameter('kernel.project_dir', 'foo');
$adapter = new Definition();
$adapter->setAbstract(true);
$adapter->addTag('cache.pool');
$adapter->setClass(RedisAdapter::class);
$container->setDefinition('app.cache_adapter', $adapter);
$container->setAlias('app.cache_adapter_alias', 'app.cache_adapter');
$otherCachePool = new ChildDefinition('app.cache_adapter_alias');
$otherCachePool->addArgument(null);
$otherCachePool->addTag('cache.pool');
$container->setDefinition('app.other_cache_pool', $otherCachePool);
$cachePool = new ChildDefinition('app.cache_adapter_alias');
$cachePool->addArgument(null);
$cachePool->addTag('cache.pool');
$container->setDefinition('app.cache_pool', $cachePool);
$this->cachePoolPass->process($container);
$this->assertSame('xmOJ8gqF-Y', $cachePool->getArgument(0));
}
public function testNamespaceArgumentIsNotReplacedIfArrayAdapterIsUsed()
{
$container = new ContainerBuilder();

View File

@ -164,11 +164,11 @@ class RouterListener implements EventSubscriberInterface
private function createWelcomeResponse(): Response
{
$version = Kernel::VERSION;
$baseDir = realpath($this->projectDir).\DIRECTORY_SEPARATOR;
$projectDir = realpath($this->projectDir).\DIRECTORY_SEPARATOR;
$docVersion = substr(Kernel::VERSION, 0, 3);
ob_start();
include __DIR__.'/../Resources/welcome.html.php';
include \dirname(__DIR__).'/Resources/welcome.html.php';
return new Response(ob_get_clean(), Response::HTTP_NOT_FOUND);
}

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@ use Symfony\Component\Mime\RawMessage;
use Symfony\Contracts\EventDispatcher\Event;
/**
* Allows the transformation of a Message and the SMTP Envelope before the email is sent.
* Allows the transformation of a Message and the Envelope before the email is sent.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
@ -45,12 +45,12 @@ final class MessageEvent extends Event
$this->message = $message;
}
public function getEnvelope(): SmtpEnvelope
public function getEnvelope(): Envelope
{
return $this->envelope;
}
public function setEnvelope(SmtpEnvelope $envelope): void
public function setEnvelope(Envelope $envelope): void
{
$this->envelope = $envelope;
}

View File

@ -263,12 +263,12 @@ class ValidatorBuilder
*/
public function setMappingCache(CacheItemPoolInterface $cache)
{
$this->mappingCache = $cache;
if (null !== $this->metadataFactory) {
throw new ValidatorException('You cannot set a custom mapping cache after setting a custom metadata factory. Configure your metadata factory instead.');
}
$this->mappingCache = $cache;
return $this;
}

View File

@ -674,7 +674,7 @@ class Inline
$nextOffset += strspn($value, ' ', $nextOffset);
// Is followed by a scalar and is a built-in tag
if ($tag && (!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], true)) && ('!' === $tag[0] || 'str' === $tag || 'php/const' === $tag || 'php/object' === $tag)) {
if ('' !== $tag && (!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], ['[', '{'], true)) && ('!' === $tag[0] || 'str' === $tag || 'php/const' === $tag || 'php/object' === $tag)) {
// Manage in {@link self::evaluateScalar()}
return null;
}
@ -682,10 +682,14 @@ class Inline
$i = $nextOffset;
// Built-in tags
if ($tag && '!' === $tag[0]) {
if ('' !== $tag && '!' === $tag[0]) {
throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}
if ('' !== $tag && !isset($value[$i])) {
throw new ParseException(sprintf('Missing value for tag "%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}
if ('' === $tag || Yaml::PARSE_CUSTOM_TAGS & $flags) {
return $tag;
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Yaml\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Tag\TaggedValue;
use Symfony\Component\Yaml\Yaml;
@ -1840,6 +1841,14 @@ YAML;
$this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT));
}
public function testDeprecatedPhpConstantSyntax()
{
$this->expectException(ParseException::class);
$this->expectExceptionMessage('Missing value for tag "php/const:App\Kernel::SEMART_VERSION" at line 1 (near "!php/const:App\Kernel::SEMART_VERSION").');
$this->parser->parse('!php/const:App\Kernel::SEMART_VERSION', Yaml::PARSE_CUSTOM_TAGS | Yaml::PARSE_CONSTANT);
}
public function testMergeKeysWhenMappingsAreParsedAsObjects()
{
$yaml = <<<YAML