diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php index 655e95cf93..c14399c0c6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php @@ -423,7 +423,7 @@ class Configuration implements ConfigurationInterface ->addDefaultChildrenIfNoneSet() ->prototype('scalar')->defaultValue('FrameworkBundle:Form')->end() ->validate() - ->ifNotInArray(array('FrameworkBundle:Form')) + ->ifTrue(function ($v) {return !in_array('FrameworkBundle:Form', $v); }) ->then(function ($v) { return array_merge(array('FrameworkBundle:Form'), $v); }) diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php index a4a5e92cf3..df3ab19c4d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php @@ -31,7 +31,7 @@ class TemplateFilenameParser implements TemplateNameParserInterface return $name; } - $parts = explode('/', strtr($name, '\\', '/')); + $parts = explode('/', str_replace('\\', '/', $name)); $elements = explode('.', array_pop($parts)); if (3 > count($elements)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php index 5730807fac..e4a7053d25 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php @@ -49,7 +49,7 @@ class TemplateNameParser extends BaseTemplateNameParser } // normalize name - $name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', strtr($name, '\\', '/'))); + $name = str_replace(':/', ':', preg_replace('#/{2,}#', '/', str_replace('\\', '/', $name))); if (false !== strpos($name, '..')) { throw new \RuntimeException(sprintf('Template name "%s" contains invalid characters.', $name)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 47482433a9..89777ac44f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -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 */ diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php index 9056ea299e..52c70f3318 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php @@ -81,7 +81,7 @@ class Configuration implements ConfigurationInterface ->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end() ->example(array('MyBundle::form.html.twig')) ->validate() - ->ifNotInArray(array('form_div_layout.html.twig')) + ->ifTrue(function ($v) {return !in_array('form_div_layout.html.twig', $v); }) ->then(function ($v) { return array_merge(array('form_div_layout.html.twig'), $v); }) diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php new file mode 100644 index 0000000000..7160345fd3 --- /dev/null +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -0,0 +1,30 @@ + + * + * 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']); + } +} diff --git a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php index e6756f1898..7bdf5aa0dc 100644 --- a/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php +++ b/src/Symfony/Component/ClassLoader/Tests/ClassMapGeneratorTest.php @@ -140,10 +140,10 @@ class ClassMapGeneratorTest extends \PHPUnit_Framework_TestCase protected function assertEqualsNormalized($expected, $actual, $message = null) { foreach ($expected as $ns => $path) { - $expected[$ns] = strtr($path, '\\', '/'); + $expected[$ns] = str_replace('\\', '/', $path); } foreach ($actual as $ns => $path) { - $actual[$ns] = strtr($path, '\\', '/'); + $actual[$ns] = str_replace('\\', '/', $path); } $this->assertEquals($expected, $actual, $message); } diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 4a77f939ad..1e62b4d05d 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -329,8 +329,8 @@ class Filesystem { // Normalize separators on Windows if ('\\' === DIRECTORY_SEPARATOR) { - $endPath = strtr($endPath, '\\', '/'); - $startPath = strtr($startPath, '\\', '/'); + $endPath = str_replace('\\', '/', $endPath); + $startPath = str_replace('\\', '/', $startPath); } // Split the paths into arrays diff --git a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php index 1ddde851b9..f15d953e4d 100644 --- a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php @@ -43,7 +43,7 @@ class ExcludeDirectoryFilterIterator extends FilterIterator public function accept() { $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath(); - $path = strtr($path, '\\', '/'); + $path = str_replace('\\', '/', $path); foreach ($this->patterns as $pattern) { if (preg_match($pattern, $path)) { return false; diff --git a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php index 2bb8ebd223..4971692c69 100644 --- a/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/PathFilterIterator.php @@ -29,7 +29,7 @@ class PathFilterIterator extends MultiplePcreFilterIterator $filename = $this->current()->getRelativePathname(); if ('\\' === DIRECTORY_SEPARATOR) { - $filename = strtr($filename, '\\', '/'); + $filename = str_replace('\\', '/', $filename); } // should at least not match one rule to exclude