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 unix line endings file task.
23 * @author Greg Beaver <cellog@php.net>
24 * @copyright 1997-2009 The Authors
25 * @license http://opensource.org/licenses/bsd-license.php New BSD License
26 * @version Release: 1.10.1
27 * @link http://pear.php.net/package/PEAR
28 * @since Class available since Release 1.4.0a1
30 class PEAR_Task_Unixeol extends PEAR_Task_Common
32 public $type = 'simple';
33 public $phase = PEAR_TASK_PACKAGE;
34 public $_replacements;
37 * Validate the raw xml at parsing-time.
39 * @param PEAR_PackageFile_v2
40 * @param array raw, parsed xml
43 public static function validateXml($pkg, $xml, $config, $fileXml)
46 return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed');
53 * Initialize a task instance with the parameters
54 * @param array raw, parsed xml
58 public function init($xml, $attribs, $lastVersion = null)
63 * Replace all line endings with line endings customized for the current OS
65 * See validateXml() source for the complete list of allowed fields
67 * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
68 * @param string file contents
69 * @param string the eventual final file location (informational only)
70 * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
71 * (use $this->throwError), otherwise return the new contents
73 public function startSession($pkg, $contents, $dest)
75 $this->logger->log(3, "replacing all line endings with \\n in $dest");
77 return preg_replace("/\r\n|\n\r|\r|\n/", "\n", $contents);