diff --git a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
index 6fdd0a4b6b..f811cd0a71 100644
--- a/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
+++ b/src/Symfony/Component/ClassLoader/ClassCollectionLoader.php
@@ -116,8 +116,8 @@ class ClassCollectionLoader
}
// cache the core classes
- if (!is_dir(dirname($cache))) {
- mkdir(dirname($cache), 0777, true);
+ if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777, true) && !is_dir($cacheDir)) {
+ throw new \RuntimeException(sprintf('Class Collection Loader was not able to create directory "%s"', $cacheDir));
}
self::writeCacheFile($cache, 'getName());
$output = str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $argument->getDescription());
- $output = sprintf(" %-${nameWidth}s %s%s", $argument->getName(), $output, $default);
+ $output = sprintf(" %-{$nameWidth}s %s%s", $argument->getName(), $output, $default);
return isset($options['raw_text']) && $options['raw_text'] ? strip_tags($output) : $output;
}
@@ -56,7 +56,7 @@ class TextDescriptor extends Descriptor
$nameWidth = isset($options['name_width']) ? $options['name_width'] : strlen($option->getName());
$nameWithShortcutWidth = $nameWidth - strlen($option->getName()) - 2;
- $output = sprintf(" %s %-${nameWithShortcutWidth}s%s%s%s",
+ $output = sprintf(" %s %-{$nameWithShortcutWidth}s%s%s%s",
'--'.$option->getName(),
$option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '',
str_replace("\n", "\n".str_repeat(' ', $nameWidth + 2), $option->getDescription()),
@@ -146,7 +146,7 @@ class TextDescriptor extends Descriptor
$width = $this->getColumnWidth($description->getCommands());
foreach ($description->getCommands() as $command) {
- $messages[] = sprintf("%-${width}s %s", $command->getName(), $command->getDescription());
+ $messages[] = sprintf("%-{$width}s %s", $command->getName(), $command->getDescription());
}
} else {
$width = $this->getColumnWidth($description->getCommands());
@@ -167,7 +167,7 @@ class TextDescriptor extends Descriptor
}
foreach ($namespace['commands'] as $name) {
- $messages[] = sprintf(" %-${width}s %s", $name, $description->getCommand($name)->getDescription());
+ $messages[] = sprintf(" %-{$width}s %s", $name, $description->getCommand($name)->getDescription());
}
}
}
diff --git a/src/Symfony/Component/Console/Helper/DialogHelper.php b/src/Symfony/Component/Console/Helper/DialogHelper.php
index fbb0f06623..4053e34dbf 100644
--- a/src/Symfony/Component/Console/Helper/DialogHelper.php
+++ b/src/Symfony/Component/Console/Helper/DialogHelper.php
@@ -46,7 +46,7 @@ class DialogHelper extends Helper
$messages = (array) $question;
foreach ($choices as $key => $value) {
- $messages[] = sprintf(" [%-${width}s] %s", $key, $value);
+ $messages[] = sprintf(" [%-{$width}s] %s", $key, $value);
}
$output->writeln($messages);
diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php
index f39235cbfb..c00835d797 100644
--- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php
+++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NativeFileSessionHandler.php
@@ -48,8 +48,8 @@ class NativeFileSessionHandler extends NativeSessionHandler
$baseDir = ltrim(strrchr($savePath, ';'), ';');
}
- if ($baseDir && !is_dir($baseDir)) {
- mkdir($baseDir, 0777, true);
+ if ($baseDir && !is_dir($baseDir) && !@mkdir($baseDir, 0777, true) && !is_dir($baseDir)) {
+ throw new \RuntimeException(sprintf('Session Storage was not able to create directory "%s"', $baseDir));
}
ini_set('session.save_path', $savePath);
diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php
index 1f4117b74e..00807cfcb7 100644
--- a/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php
+++ b/src/Symfony/Component/HttpFoundation/Session/Storage/MockFileSessionStorage.php
@@ -42,8 +42,8 @@ class MockFileSessionStorage extends MockArraySessionStorage
$savePath = sys_get_temp_dir();
}
- if (!is_dir($savePath)) {
- mkdir($savePath, 0777, true);
+ if (!is_dir($savePath) && !@mkdir($savePath, 0777, true) && !is_dir($savePath)) {
+ throw new \RuntimeException(sprintf('Session Storage was not able to create directory "%s"', $savePath));
}
$this->savePath = $savePath;
diff --git a/src/Symfony/Component/Templating/Loader/CacheLoader.php b/src/Symfony/Component/Templating/Loader/CacheLoader.php
index 53e0f9ecc5..c007a2527c 100644
--- a/src/Symfony/Component/Templating/Loader/CacheLoader.php
+++ b/src/Symfony/Component/Templating/Loader/CacheLoader.php
@@ -69,8 +69,8 @@ class CacheLoader extends Loader
$content = $storage->getContent();
- if (!is_dir($dir)) {
- mkdir($dir, 0777, true);
+ if (!is_dir($dir) && !@mkdir($dir, 0777, true) && !is_dir($dir)) {
+ throw new \RuntimeException(sprintf('Cache Loader was not able to create directory "%s"', $dir));
}
file_put_contents($path, $content);
diff --git a/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php b/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php
index 2da7cf33b3..4b42a92ee9 100644
--- a/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php
+++ b/src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php
@@ -34,8 +34,8 @@ class IcuResFileDumper implements DumperInterface
$file = $messages->getLocale().'.'.$this->getExtension();
$path = $options['path'].'/'.$domain.'/';
- if (!file_exists($path)) {
- mkdir($path);
+ if (!is_dir($path) && !@mkdir($path) && !is_dir($path)) {
+ throw new \RuntimeException(sprintf('File Dumper was not able to create directory "%s"', $path));
}
// backup
@@ -102,11 +102,7 @@ class IcuResFileDumper implements DumperInterface
1, 4, 0, 0 // Unicode version
);
- $output = $header
- .$root
- .$data;
-
- return $output;
+ return $header.$root.$data;
}
private function writePadding($data)
@@ -120,9 +116,7 @@ class IcuResFileDumper implements DumperInterface
private function getPosition($data)
{
- $position = (strlen($data) + 28) / 4;
-
- return $position;
+ return (strlen($data) + 28) / 4;
}
/**
diff --git a/src/Symfony/Component/Translation/Writer/TranslationWriter.php b/src/Symfony/Component/Translation/Writer/TranslationWriter.php
index d78bfa98ac..d5bbb0ded9 100644
--- a/src/Symfony/Component/Translation/Writer/TranslationWriter.php
+++ b/src/Symfony/Component/Translation/Writer/TranslationWriter.php
@@ -67,8 +67,8 @@ class TranslationWriter
// get the right dumper
$dumper = $this->dumpers[$format];
- if (isset($options['path']) && !is_dir($options['path'])) {
- mkdir($options['path'], 0777, true);
+ if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0777, true) && !is_dir($options['path'])) {
+ throw new \RuntimeException(sprintf('Translation Writer was not able to create directory "%s"', $options['path']));
}
// save