Skip to content

Commit 5edacf0

Browse files
kalessilfabpot
authored andcommitted
[2.3] Static Code Analysis for Components
1 parent 08cb7fb commit 5edacf0

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

Dumper/IcuResFileDumper.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function dump(MessageCatalogue $messages, $options = array())
3434
$file = $messages->getLocale().'.'.$this->getExtension();
3535
$path = $options['path'].'/'.$domain.'/';
3636

37-
if (!file_exists($path)) {
38-
mkdir($path);
37+
if (!is_dir($path) && !@mkdir($path) && !is_dir($path)) {
38+
throw new \RuntimeException(sprintf('File Dumper was not able to create directory "%s"', $path));
3939
}
4040

4141
// backup
@@ -102,11 +102,7 @@ public function format(MessageCatalogue $messages, $domain = 'messages')
102102
1, 4, 0, 0 // Unicode version
103103
);
104104

105-
$output = $header
106-
.$root
107-
.$data;
108-
109-
return $output;
105+
return $header.$root.$data;
110106
}
111107

112108
private function writePadding($data)
@@ -120,9 +116,7 @@ private function writePadding($data)
120116

121117
private function getPosition($data)
122118
{
123-
$position = (strlen($data) + 28) / 4;
124-
125-
return $position;
119+
return (strlen($data) + 28) / 4;
126120
}
127121

128122
/**

Writer/TranslationWriter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public function writeTranslations(MessageCatalogue $catalogue, $format, $options
6767
// get the right dumper
6868
$dumper = $this->dumpers[$format];
6969

70-
if (isset($options['path']) && !is_dir($options['path'])) {
71-
mkdir($options['path'], 0777, true);
70+
if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0777, true) && !is_dir($options['path'])) {
71+
throw new \RuntimeException(sprintf('Translation Writer was not able to create directory "%s"', $options['path']));
7272
}
7373

7474
// save

0 commit comments

Comments
 (0)