diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 785c7a0922..cbfa98c2e5 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -158,12 +158,13 @@ class Filesystem $files = iterator_to_array($this->toIterator($files)); $files = array_reverse($files); foreach ($files as $file) { + if (@(unlink($file) || rmdir($file))) { + continue; + } if (is_link($file)) { - // Workaround https://bugs.php.net/52176 - if (!@unlink($file) && !@rmdir($file)) { - $error = error_get_last(); - throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, $error['message'])); - } + // See https://bugs.php.net/52176 + $error = error_get_last(); + throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, $error['message'])); } elseif (is_dir($file)) { $this->remove(new \FilesystemIterator($file)); @@ -171,11 +172,9 @@ class Filesystem $error = error_get_last(); throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, $error['message'])); } - } elseif ($this->exists($file)) { - if (!@unlink($file)) { - $error = error_get_last(); - throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message'])); - } + } elseif (file_exists($file)) { + $error = error_get_last(); + throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message'])); } } } @@ -435,7 +434,7 @@ class Filesystem $target = str_replace($originDir, $targetDir, $file->getPathname()); if ($copyOnWindows) { - if (is_link($file) || is_file($file)) { + if (is_file($file)) { $this->copy($file, $target, isset($options['override']) ? $options['override'] : false); } elseif (is_dir($file)) { $this->mkdir($target); diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 6d63a42aa1..0ca2904833 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -744,6 +744,8 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->remove($link); $this->assertTrue(!is_link($link)); + $this->assertTrue(!is_file($link)); + $this->assertTrue(!is_dir($link)); } public function testSymlinkIsOverwrittenIfPointsToDifferentTarget() @@ -917,7 +919,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->mirror($sourcePath, $targetPath); $this->assertTrue(is_dir($targetPath)); - $this->assertFileEquals($sourcePath.'file1', $targetPath.DIRECTORY_SEPARATOR.'link1'); + $this->assertFileEquals($sourcePath.'file1', $targetPath.'link1'); $this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1')); } @@ -937,7 +939,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->mirror($sourcePath, $targetPath); $this->assertTrue(is_dir($targetPath)); - $this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt'); + $this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt'); $this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1')); } @@ -961,7 +963,7 @@ class FilesystemTest extends FilesystemTestCase $this->filesystem->mirror($sourcePath, $targetPath); $this->assertTrue(is_dir($targetPath)); - $this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt'); + $this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt'); $this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1')); $this->assertEquals('\\' === DIRECTORY_SEPARATOR ? realpath($sourcePath.'\nested') : 'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1')); } diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php index 1f245f49b5..c1ef723994 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php @@ -36,9 +36,8 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase if ('\\' === DIRECTORY_SEPARATOR && null === self::$symlinkOnWindows) { $target = tempnam(sys_get_temp_dir(), 'sl'); $link = sys_get_temp_dir().'/sl'.microtime(true).mt_rand(); - if (self::$symlinkOnWindows = @symlink($target, $link)) { - unlink($link); - } + self::$symlinkOnWindows = @symlink($target, $link) && is_link($link); + @unlink($link); unlink($target); } } diff --git a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php index 038a1a47b0..e998c33877 100644 --- a/src/Symfony/Component/Validator/Constraints/LocaleValidator.php +++ b/src/Symfony/Component/Validator/Constraints/LocaleValidator.php @@ -43,8 +43,9 @@ class LocaleValidator extends ConstraintValidator $value = (string) $value; $locales = Intl::getLocaleBundle()->getLocaleNames(); + $aliases = Intl::getLocaleBundle()->getAliases(); - if (!isset($locales[$value])) { + if (!isset($locales[$value]) && !in_array($value, $aliases)) { if ($this->context instanceof ExecutionContextInterface) { $this->context->buildViolation($constraint->message) ->setParameter('{{ value }}', $this->formatValue($value)) diff --git a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php index c019fdf37e..823a861e85 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/LocaleValidatorTest.php @@ -67,6 +67,7 @@ class LocaleValidatorTest extends AbstractConstraintValidatorTest array('pt'), array('pt_PT'), array('zh_Hans'), + array('fil_PH'), ); } diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index 463a686e7f..effc4d7db4 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -22,7 +22,7 @@ "require-dev": { "doctrine/common": "~2.3", "symfony/http-foundation": "~2.1", - "symfony/intl": "~2.4", + "symfony/intl": "~2.7.4", "symfony/yaml": "~2.0,>=2.0.5", "symfony/config": "~2.2", "symfony/property-access": "~2.3",