Merge branch '2.7' into 2.8
* 2.7: [Twig] Fix deprecations with Twig 1.29 fix the docblock in regard to the role argument Cast result to int before adding to it
This commit is contained in:
commit
7f633d143c
@ -73,7 +73,6 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @expectedException \Twig_Error
|
||||
* @expectedExceptionMessageRegExp /Unclosed "block" in ".*extractor(\/|\\)syntax_error\.twig" at line 1/
|
||||
* @dataProvider resourcesWithSyntaxErrorsProvider
|
||||
*/
|
||||
public function testExtractSyntaxError($resources)
|
||||
@ -82,7 +81,19 @@ class TwigExtractorTest extends \PHPUnit_Framework_TestCase
|
||||
$twig->addExtension(new TranslationExtension($this->getMock('Symfony\Component\Translation\TranslatorInterface')));
|
||||
|
||||
$extractor = new TwigExtractor($twig);
|
||||
|
||||
try {
|
||||
$extractor->extract($resources, new MessageCatalogue('en'));
|
||||
} catch (\Twig_Error $e) {
|
||||
if (method_exists($e, 'getSourceContext')) {
|
||||
$this->assertSame(dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', DIRECTORY_SEPARATOR), $e->getFile());
|
||||
$this->assertSame(1, $e->getLine());
|
||||
$this->assertSame('Unclosed "block".', $e->getMessage());
|
||||
} else {
|
||||
$this->expectExceptionMessageRegExp('/Unclosed "block" in ".*extractor(\\/|\\\\)syntax_error\\.twig" at line 1/');
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,10 +61,14 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface
|
||||
try {
|
||||
$this->extractTemplate(file_get_contents($file->getPathname()), $catalogue);
|
||||
} catch (\Twig_Error $e) {
|
||||
if ($file instanceof SplFileInfo) {
|
||||
$e->setTemplateName($file->getRelativePathname());
|
||||
} elseif ($file instanceof \SplFileInfo) {
|
||||
$e->setTemplateName($file->getRealPath() ?: $file->getPathname());
|
||||
if ($file instanceof \SplFileInfo) {
|
||||
$path = $file->getRealPath() ?: $file->getPathname();
|
||||
$name = $file instanceof SplFileInfo ? $file->getRelativePathname() : $path;
|
||||
if (method_exists($e, 'setSourceContext')) {
|
||||
$e->setSourceContext(new \Twig_Source('', $name, $path));
|
||||
} else {
|
||||
$e->setTemplateName($name);
|
||||
}
|
||||
}
|
||||
|
||||
throw $e;
|
||||
|
@ -74,7 +74,13 @@ class TwigEngine extends BaseEngine implements EngineInterface
|
||||
if ($name instanceof TemplateReference) {
|
||||
try {
|
||||
// try to get the real name of the template where the error occurred
|
||||
$e->setTemplateName(sprintf('%s', $this->locator->locate($this->parser->parse($e->getTemplateName()))));
|
||||
$name = $e->getTemplateName();
|
||||
$path = (string) $this->locator->locate($this->parser->parse($name));
|
||||
if (method_exists($e, 'setSourceContext')) {
|
||||
$e->setSourceContext(new \Twig_Source('', $name, $path));
|
||||
} else {
|
||||
$e->setTemplateName($path);
|
||||
}
|
||||
} catch (\Exception $e2) {
|
||||
}
|
||||
}
|
||||
|
@ -72,9 +72,11 @@
|
||||
<ul id="menu-profiler">
|
||||
{% for name, template in templates %}
|
||||
{% set menu -%}
|
||||
{% if block('menu', template) is defined %}
|
||||
{% with { collector: profile.getcollector(name), profiler_markup_version: profiler_markup_version } %}
|
||||
{{- block('menu', template) -}}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{%- endset %}
|
||||
{% if menu is not empty %}
|
||||
<li class="{{ name }} {{ name == panel ? 'selected' : '' }}">
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
<div id="sfToolbarMainContent-{{ token }}" class="sf-toolbarreset clear-fix" data-no-turbolink>
|
||||
{% for name, template in templates %}
|
||||
{% if block('toolbar', template) is defined %}
|
||||
{% with {
|
||||
collector: profile.getcollector(name),
|
||||
profiler_url: profiler_url,
|
||||
@ -35,6 +36,7 @@
|
||||
} %}
|
||||
{{ block('toolbar', template) }}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if 'normal' != position %}
|
||||
|
@ -369,21 +369,22 @@ class XmlFileLoader extends FileLoader
|
||||
$arg->setAttribute('key', $arg->getAttribute('name'));
|
||||
}
|
||||
|
||||
if (!$arg->hasAttribute('key')) {
|
||||
$key = !$arguments ? 0 : max(array_keys($arguments)) + 1;
|
||||
// this is used by DefinitionDecorator to overwrite a specific
|
||||
// argument of the parent definition
|
||||
if ($arg->hasAttribute('index')) {
|
||||
$key = 'index_'.$arg->getAttribute('index');
|
||||
} elseif (!$arg->hasAttribute('key')) {
|
||||
// Append an empty argument, then fetch its key to overwrite it later
|
||||
$arguments[] = null;
|
||||
$keys = array_keys($arguments);
|
||||
$key = array_pop($keys);
|
||||
} else {
|
||||
$key = $arg->getAttribute('key');
|
||||
}
|
||||
|
||||
// parameter keys are case insensitive
|
||||
if ('parameter' == $name && $lowercase) {
|
||||
$key = strtolower($key);
|
||||
}
|
||||
|
||||
// this is used by DefinitionDecorator to overwrite a specific
|
||||
// argument of the parent definition
|
||||
if ($arg->hasAttribute('index')) {
|
||||
$key = 'index_'.$arg->getAttribute('index');
|
||||
}
|
||||
|
||||
switch ($arg->getAttribute('type')) {
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
<services>
|
||||
<service id="foo" class="Foo">
|
||||
<argument key="type">foo</argument>
|
||||
<argument>bar</argument>
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
@ -577,4 +577,13 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertTrue($container->getDefinition('bar')->isAutowired());
|
||||
}
|
||||
|
||||
public function testArgumentWithKeyOutsideCollection()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
|
||||
$loader->load('with_key_outside_collection.xml');
|
||||
|
||||
$this->assertSame(array('type' => 'foo', 'bar'), $container->getDefinition('foo')->getArguments());
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ abstract class AbstractToken implements TokenInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param RoleInterface[]|string[] $roles An array of roles
|
||||
* @param (RoleInterface|string)[] $roles An array of roles
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ class PreAuthenticatedToken extends AbstractToken
|
||||
* @param string|object $user The user can be a UserInterface instance, or an object implementing a __toString method or the username as a regular string
|
||||
* @param mixed $credentials The user credentials
|
||||
* @param string $providerKey The provider key
|
||||
* @param RoleInterface[]|string[] $roles An array of roles
|
||||
* @param (RoleInterface|string)[] $roles An array of roles
|
||||
*/
|
||||
public function __construct($user, $credentials, $providerKey, array $roles = array())
|
||||
{
|
||||
|
@ -29,7 +29,7 @@ class UsernamePasswordToken extends AbstractToken
|
||||
* @param string|object $user The username (like a nickname, email address, etc.), or a UserInterface instance or an object implementing a __toString method
|
||||
* @param string $credentials This usually is the password of the user
|
||||
* @param string $providerKey The provider key
|
||||
* @param RoleInterface[]|string[] $roles An array of roles
|
||||
* @param (RoleInterface|string)[] $roles An array of roles
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
|
Reference in New Issue
Block a user