9 * @author Greg Beaver <cellog@php.net>
10 * @copyright 1997-2009 The Authors
11 * @license http://opensource.org/licenses/bsd-license.php New BSD License
12 * @link http://pear.php.net/package/PEAR
13 * @since File available since Release 1.4.0a1
18 require_once 'PEAR/Task/Common.php';
20 * Implements the windows line endsings file task.
24 * @author Greg Beaver <cellog@php.net>
25 * @copyright 1997-2009 The Authors
26 * @license http://opensource.org/licenses/bsd-license.php New BSD License
27 * @version Release: 1.10.1
28 * @link http://pear.php.net/package/PEAR
29 * @since Class available since Release 1.4.0a1
31 class PEAR_Task_Windowseol extends PEAR_Task_Common
33 public $type = 'simple';
34 public $phase = PEAR_TASK_PACKAGE;
35 public $_replacements;
38 * Validate the raw xml at parsing-time.
40 * @param PEAR_PackageFile_v2
41 * @param array raw, parsed xml
44 public static function validateXml($pkg, $xml, $config, $fileXml)
47 return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed');
54 * Initialize a task instance with the parameters
55 * @param array raw, parsed xml
59 public function init($xml, $attribs, $lastVersion = null)
64 * Replace all line endings with windows line endings
66 * See validateXml() source for the complete list of allowed fields
68 * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
69 * @param string file contents
70 * @param string the eventual final file location (informational only)
71 * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
72 * (use $this->throwError), otherwise return the new contents
74 public function startSession($pkg, $contents, $dest)
76 $this->logger->log(3, "replacing all line endings with \\r\\n in $dest");
78 return preg_replace("/\r\n|\n\r|\r|\n/", "\r\n", $contents);