Merge branch '2.3' into 2.7

Conflicts:
	src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php
This commit is contained in:
Tobias Schultze 2015-08-26 19:56:37 +02:00
commit 755f3c0223
10 changed files with 53 additions and 10 deletions

View File

@ -423,7 +423,7 @@ class Configuration implements ConfigurationInterface
->addDefaultChildrenIfNoneSet() ->addDefaultChildrenIfNoneSet()
->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end() ->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end()
->validate() ->validate()
->ifNotInArray(array('FrameworkBundle:Form')) ->ifTrue(function ($v) {return !in_array('FrameworkBundle:Form', $v); })
->then(function ($v) { ->then(function ($v) {
return array_merge(array('FrameworkBundle:Form'), $v); return array_merge(array('FrameworkBundle:Form'), $v);
}) })

View File

@ -31,7 +31,7 @@ class TemplateFilenameParser implements TemplateNameParserInterface
return $name; return $name;
} }
$parts = explode('/', strtr($name, '\\', '/')); $parts = explode('/', str_replace('\\', '/', $name));
$elements = explode('.', array_pop($parts)); $elements = explode('.', array_pop($parts));
if (3 > count($elements)) { if (3 > count($elements)) {

View File

@ -49,7 +49,7 @@ class TemplateNameParser extends BaseTemplateNameParser
} }
// normalize name // normalize name
$name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', strtr($name, '\\', '/'))); $name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name)));
if (false !== strpos($name, '..')) { if (false !== strpos($name, '..')) {
throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name)); throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name));

View File

@ -27,6 +27,19 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
); );
} }
public function testDoNoDuplicateDefaultFormResources()
{
$input = array('templating' => array(
'form' => array('resources' => array('FrameworkBundle:Form')),
'engines' => array('php'),
));
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), array($input));
$this->assertEquals(array('FrameworkBundle:Form'), $config['templating']['form']['resources']);
}
/** /**
* @dataProvider getTestValidTrustedProxiesData * @dataProvider getTestValidTrustedProxiesData
*/ */

View File

@ -81,7 +81,7 @@ class Configuration implements ConfigurationInterface
->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end() ->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()
->example(array('MyBundle::form.html.twig')) ->example(array('MyBundle::form.html.twig'))
->validate() ->validate()
->ifNotInArray(array('form_div_layout.html.twig')) ->ifTrue(function ($v) {return !in_array('form_div_layout.html.twig', $v); })
->then(function ($v) { ->then(function ($v) {
return array_merge(array('form_div_layout.html.twig'), $v); return array_merge(array('form_div_layout.html.twig'), $v);
}) })

View File

@ -0,0 +1,30 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection;
use Symfony\Bundle\TwigBundle\DependencyInjection\Configuration;
use Symfony\Component\Config\Definition\Processor;
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
public function testDoNoDuplicateDefaultFormResources()
{
$input = array(
'form' => array('resources' => array('form_div_layout.html.twig')),
);
$processor = new Processor();
$config = $processor->processConfiguration(new Configuration(), array($input));
$this->assertEquals(array('form_div_layout.html.twig'), $config['form']['resources']);
}
}

View File

@ -140,10 +140,10 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase
protected function assertEqualsNormalized($expected, $actual, $message = null) protected function assertEqualsNormalized($expected, $actual, $message = null)
{ {
foreach ($expected as $ns => $path) { foreach ($expected as $ns => $path) {
$expected[$ns] = strtr($path, '\\', '/'); $expected[$ns] = str_replace('\\', '/', $path);
} }
foreach ($actual as $ns => $path) { foreach ($actual as $ns => $path) {
$actual[$ns] = strtr($path, '\\', '/'); $actual[$ns] = str_replace('\\', '/', $path);
} }
$this->assertEquals($expected, $actual, $message); $this->assertEquals($expected, $actual, $message);
} }

View File

@ -329,8 +329,8 @@ class Filesystem
{ {
// Normalize separators on Windows // Normalize separators on Windows
if ('\\' === DIRECTORY_SEPARATOR) { if ('\\' === DIRECTORY_SEPARATOR) {
$endPath = strtr($endPath, '\\', '/'); $endPath = str_replace('\\', '/', $endPath);
$startPath = strtr($startPath, '\\', '/'); $startPath = str_replace('\\', '/', $startPath);
} }
// Split the paths into arrays // Split the paths into arrays

View File

@ -43,7 +43,7 @@ class ExcludeDirectoryFilterIterator extends FilterIterator
public function accept() public function accept()
{ {
$path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath(); $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
$path = strtr($path, '\\', '/'); $path = str_replace('\\', '/', $path);
foreach ($this->patterns as $pattern) { foreach ($this->patterns as $pattern) {
if (preg_match($pattern, $path)) { if (preg_match($pattern, $path)) {
return false; return false;

View File

@ -29,7 +29,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator
$filename = $this->current()->getRelativePathname(); $filename = $this->current()->getRelativePathname();
if ('\\' === DIRECTORY_SEPARATOR) { if ('\\' === DIRECTORY_SEPARATOR) {
$filename = strtr($filename, '\\', '/'); $filename = str_replace('\\', '/', $filename);
} }
// should at least not match one rule to exclude // should at least not match one rule to exclude