getExtension() == 'php') { echo "Removing comments from: " . $file->getRealPath() . "\n"; $contents = file_get_contents($file->getRealPath()); $new = preg_replace('/^(\{?)\s*?\/\*(.|[\r\n])*?\*\/([\r\n]+$|$)/im', '$1', $contents); file_put_contents($file->getRealPath(), $new); } } }