Explicitly initialize anonModule to null.
[htmlpurifier.git] / maintenance / remove-trailing-whitespace.php
blob857870546a1d3cb8fa3d8c66a62533b12170952d
1 #!/usr/bin/php
2 <?php
4 chdir(dirname(__FILE__));
5 require_once 'common.php';
6 assertCli();
8 /**
9 * @file
10 * Removes trailing whitespace from files.
13 chdir(dirname(__FILE__) . '/..');
14 $FS = new FSTools();
16 $files = $FS->globr('.', '{,.}*', GLOB_BRACE);
17 foreach ($files as $file) {
18 if (
19 !is_file($file) ||
20 prefix_is('./.git', $file) ||
21 prefix_is('./docs/doxygen', $file) ||
22 postfix_is('.ser', $file) ||
23 postfix_is('.tgz', $file) ||
24 postfix_is('.patch', $file) ||
25 postfix_is('.dtd', $file) ||
26 postfix_is('.ent', $file) ||
27 $file == './library/HTMLPurifier/Lexer/PH5P.php' ||
28 $file == './maintenance/PH5P.php'
29 ) continue;
30 $contents = file_get_contents($file);
31 $result = preg_replace('/^(.*?)[ \t]+(\r?)$/m', '\1\2', $contents, -1, $count);
32 if (!$count) continue;
33 echo "$file\n";
34 file_put_contents($file, $result);
37 // vim: et sw=4 sts=4