Skip to content

Commit a45741d

Browse files
author
Jérôme MACIAS
committed
Partialy revert 7cbbe6b
1 parent f45623e commit a45741d

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

lib/config/sfCompileConfigHandler.class.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,32 @@ public function execute($configFiles)
4848
throw new sfParseException(sprintf('Configuration file "%s" specifies nonexistent or unreadable file "%s".', $configFiles[0], $file));
4949
}
5050

51-
if (sfConfig::get('sf_debug'))
52-
{
53-
$contents = file_get_contents($file);
51+
$contents = file_get_contents($file);
5452

55-
// replace windows and mac format with unix format
56-
$contents = str_replace("\r", PHP_EOL, $contents);
57-
}
58-
else
53+
// strip comments (not in debug mode)
54+
if (!sfConfig::get('sf_debug'))
5955
{
60-
// strip whitespaces and comments
61-
$contents = php_strip_whitespace($file);
56+
$contents = sfToolkit::stripComments($contents);
6257
}
6358

6459
// strip php tags
6560
$contents = sfToolkit::pregtr($contents, array('/^\s*<\?(php\s*)?/m' => '', '/^\s*\?>/m' => ''));
6661

62+
// replace windows and mac format with unix format
63+
$contents = str_replace("\r", "\n", $contents);
64+
65+
// replace multiple new lines with a single newline
66+
$contents = preg_replace(array('/\s+$/Sm', '/\n+/S'), "\n", $contents);
67+
6768
// append file data
68-
$data .= PHP_EOL.$contents;
69+
$data .= "\n".$contents;
6970
}
7071

7172
// compile data
72-
return sprintf('<?php'.PHP_EOL.
73-
'// auto-generated by sfCompileConfigHandler'.PHP_EOL.
74-
'// date: %s'.PHP_EOL.
75-
'%s'.PHP_EOL,
73+
return sprintf("<?php\n".
74+
"// auto-generated by sfCompileConfigHandler\n".
75+
"// date: %s\n".
76+
"%s\n",
7677
date('Y/m/d H:i:s'), $data);
7778
}
7879

0 commit comments

Comments
 (0)