]> git.mxchange.org Git - friendica.git/blob - vendor/pear-pear.php.net/PEAR/PEAR/Task/Windowseol.php
Add Text_Highlighter to Composer
[friendica.git] / vendor / pear-pear.php.net / PEAR / PEAR / Task / Windowseol.php
1 <?php
2 /**
3  * <tasks:windowseol>
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 windows line endsings file task.
21  *
22  * @category  pear
23  * @package   PEAR
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.3
28  * @link      http://pear.php.net/package/PEAR
29  * @since     Class available since Release 1.4.0a1
30  */
31 class PEAR_Task_Windowseol extends PEAR_Task_Common
32 {
33     public $type = 'simple';
34     public $phase = PEAR_TASK_PACKAGE;
35     public $_replacements;
36
37     /**
38      * Validate the raw xml at parsing-time.
39      *
40      * @param  PEAR_PackageFile_v2
41      * @param  array raw, parsed xml
42      * @param  PEAR_Config
43      */
44     public static function validateXml($pkg, $xml, $config, $fileXml)
45     {
46         if ($xml != '') {
47             return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed');
48         }
49
50         return true;
51     }
52
53     /**
54      * Initialize a task instance with the parameters
55      * @param array raw, parsed xml
56      * @param unused
57      * @param unused
58      */
59     public function init($xml, $attribs, $lastVersion = null)
60     {
61     }
62
63     /**
64      * Replace all line endings with windows line endings
65      *
66      * See validateXml() source for the complete list of allowed fields
67      *
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
73      */
74     public function startSession($pkg, $contents, $dest)
75     {
76         $this->logger->log(3, "replacing all line endings with \\r\\n in $dest");
77
78         return preg_replace("/\r\n|\n\r|\r|\n/", "\r\n", $contents);
79     }
80 }