Updated PEAR and PEAR packages.
[timetracker.git] / WEB-INF / lib / pear / PEAR / Task / Unixeol.php
1 <?php
2 /**
3  * <tasks:unixeol>
4  *
5  * PHP versions 4 and 5
6  *
7  * @category  pear
8  * @package   PEAR
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
14  */
15 /**
16  * Base class
17  */
18 require_once 'PEAR/Task/Common.php';
19 /**
20  * Implements the unix line endings file task.
21  * @category   pear
22  * @package    PEAR
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
29  */
30 class PEAR_Task_Unixeol extends PEAR_Task_Common
31 {
32     public $type = 'simple';
33     public $phase = PEAR_TASK_PACKAGE;
34     public $_replacements;
35
36     /**
37      * Validate the raw xml at parsing-time.
38      *
39      * @param  PEAR_PackageFile_v2
40      * @param  array raw, parsed xml
41      * @param  PEAR_Config
42      */
43     public static function validateXml($pkg, $xml, $config, $fileXml)
44     {
45         if ($xml != '') {
46             return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed');
47         }
48
49         return true;
50     }
51
52     /**
53      * Initialize a task instance with the parameters
54      * @param array raw, parsed xml
55      * @param unused
56      * @param unused
57      */
58     public function init($xml, $attribs, $lastVersion = null)
59     {
60     }
61
62     /**
63      * Replace all line endings with line endings customized for the current OS
64      *
65      * See validateXml() source for the complete list of allowed fields
66      *
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
72      */
73     public function startSession($pkg, $contents, $dest)
74     {
75         $this->logger->log(3, "replacing all line endings with \\n in $dest");
76
77         return preg_replace("/\r\n|\n\r|\r|\n/", "\n", $contents);
78     }
79 }