Ticket #92: phing-inconsistent-newlines.diff

File phing-inconsistent-newlines.diff, 114.0 KB (added by DougWarner <silfreed-phing@…>, 5 years ago)

Reparing DOS-style newlines

  • filters/util/IniFileTokenReader.php

    diff -ru phing-orig/filters/util/IniFileTokenReader.php phing/filters/util/IniFileTokenReader.php
    old new  
    4848    /** 
    4949     * Reads the next token from the INI file 
    5050     * 
    51      * @throws  IOException     On error 
     51     * @throws  IOException     On error 
    5252     * @return Token 
    5353     */ 
    5454    function readToken() { 
  • listener/AnsiColorLogger.php

    diff -ru phing-orig/listener/AnsiColorLogger.php phing/listener/AnsiColorLogger.php
    old new  
    197197    } 
    198198 
    199199    /** 
    200      * @see DefaultLogger#printMessage 
    201      * @param string $message 
    202      * @param OutputStream $stream 
     200     * @see DefaultLogger#printMessage 
     201     * @param string $message 
     202     * @param OutputStream $stream 
    203203     * @param int $priority 
    204204     */ 
    205205    protected final function printMessage($message, OutputStream $stream, $priority) { 
     
    226226                case Project::MSG_DEBUG: 
    227227                    $message = $this->debugColor . $message . self::END_COLOR; 
    228228                    break; 
    229             } 
    230              
     229            } 
     230             
    231231            $stream->write($message . $this->lSep); 
    232232        } 
    233233    } 
  • listener/DefaultLogger.php

    diff -ru phing-orig/listener/DefaultLogger.php phing/listener/DefaultLogger.php
    old new  
    6060     *  property <em>line.seperator</em>. 
    6161     *  @var string 
    6262     */ 
    63     protected $lSep; 
    64      
    65     /** 
    66      * @var OutputStream Stream to use for standard output. 
    67      */ 
    68     protected $out; 
    69      
    70     /** 
    71      * @var OutputStream Stream to use for error output. 
    72      */ 
     63    protected $lSep; 
     64     
     65    /** 
     66     * @var OutputStream Stream to use for standard output. 
     67     */ 
     68    protected $out; 
     69     
     70    /** 
     71     * @var OutputStream Stream to use for error output. 
     72     */ 
    7373    protected $err; 
    7474 
    7575    /** 
     
    9898     * 
    9999     *  The default message level for DefaultLogger is Project::MSG_ERR. 
    100100     * 
    101      * @param int $level The logging level for the logger. 
     101     * @param int $level The logging level for the logger. 
    102102     * @see BuildLogger#setMessageOutputLevel() 
    103103     */ 
    104104    public function setMessageOutputLevel($level) { 
    105105        $this->msgOutputLevel = (int) $level; 
    106     } 
    107      
    108     /** 
    109      * Sets the output stream. 
    110      * @param OutputStream $output 
    111      * @see BuildLogger#setOutputStream() 
    112      */ 
    113     public function setOutputStream(OutputStream $output) { 
    114         $this->out = $output; 
    115     } 
    116          
    117     /** 
    118      * Sets the error stream. 
    119      * @param OutputStream $err 
    120      * @see BuildLogger#setErrorStream() 
    121      */ 
    122     public function setErrorStream(OutputStream $err) { 
    123         $this->err = $err; 
    124     } 
     106    } 
     107     
     108    /** 
     109     * Sets the output stream. 
     110     * @param OutputStream $output 
     111     * @see BuildLogger#setOutputStream() 
     112     */ 
     113    public function setOutputStream(OutputStream $output) { 
     114        $this->out = $output; 
     115    } 
     116         
     117    /** 
     118     * Sets the error stream. 
     119     * @param OutputStream $err 
     120     * @see BuildLogger#setErrorStream() 
     121     */ 
     122    public function setErrorStream(OutputStream $err) { 
     123        $this->err = $err; 
     124    } 
    125125     
    126126    /** 
    127127    *  Sets the start-time when the build started. Used for calculating 
     
    156156                $msg .= $error->getMessage(); 
    157157            } 
    158158        } 
    159         $msg .= $this->lSep . "Total time: " .self::formatTime(Phing::currentTimeMillis() - $this->startTime) . $this->lSep; 
    160          
    161         if ($error === null) { 
    162             $this->printMessage($msg, $this->out, Project::MSG_VERBOSE); 
    163         } else { 
    164             $this->printMessage($msg, $this->err, Project::MSG_ERR); 
    165         } 
    166     } 
    167  
    168         /** 
    169      * Get the message to return when a build failed. 
    170      * @return string The classic "BUILD FAILED" 
    171      */ 
    172     protected function getBuildFailedMessage() { 
    173         return "BUILD FAILED"; 
    174     } 
    175  
    176     /** 
    177      * Get the message to return when a build succeeded. 
    178      * @return string The classic "BUILD FINISHED" 
    179      */ 
    180     protected function getBuildSuccessfulMessage() { 
    181         return "BUILD FINISHED"; 
    182     } 
     159        $msg .= $this->lSep . "Total time: " .self::formatTime(Phing::currentTimeMillis() - $this->startTime) . $this->lSep; 
     160         
     161        if ($error === null) { 
     162            $this->printMessage($msg, $this->out, Project::MSG_VERBOSE); 
     163        } else { 
     164            $this->printMessage($msg, $this->err, Project::MSG_ERR); 
     165        } 
     166    } 
     167 
     168        /** 
     169     * Get the message to return when a build failed. 
     170     * @return string The classic "BUILD FAILED" 
     171     */ 
     172    protected function getBuildFailedMessage() { 
     173        return "BUILD FAILED"; 
     174    } 
     175 
     176    /** 
     177     * Get the message to return when a build succeeded. 
     178     * @return string The classic "BUILD FINISHED" 
     179     */ 
     180    protected function getBuildSuccessfulMessage() { 
     181        return "BUILD FINISHED"; 
     182    } 
    183183     
    184184    /** 
    185185     *  Prints the current target name 
     
    189189     *  @see    BuildEvent::getTarget() 
    190190     */ 
    191191    public function targetStarted(BuildEvent $event) { 
    192         if (Project::MSG_INFO <= $this->msgOutputLevel) { 
    193                 $msg = $this->lSep . $event->getProject()->getName() . ' > ' . $event->getTarget()->getName() . ':' . $this->lSep; 
     192        if (Project::MSG_INFO <= $this->msgOutputLevel) { 
     193                $msg = $this->lSep . $event->getProject()->getName() . ' > ' . $event->getTarget()->getName() . ':' . $this->lSep; 
    194194                $this->printMessage($msg, $this->out, $event->getPriority()); 
    195195        } 
    196196    } 
     
    231231     *  @access public 
    232232     *  @see    BuildEvent::getMessage() 
    233233     */ 
    234     public function messageLogged(BuildEvent $event) { 
     234    public function messageLogged(BuildEvent $event) { 
    235235        $priority = $event->getPriority(); 
    236236        if ($priority <= $this->msgOutputLevel) { 
    237237            $msg = ""; 
     
    239239                $name = $event->getTask(); 
    240240                $name = $name->getTaskName(); 
    241241                $msg = str_pad("[$name] ", self::LEFT_COLUMN_SIZE, " ", STR_PAD_LEFT); 
    242             } 
     242            } 
     243             
     244            $msg .= $event->getMessage(); 
    243245             
    244             $msg .= $event->getMessage(); 
    245              
    246             if ($priority != Project::MSG_ERR) { 
    247                 $this->printMessage($msg, $this->out, $priority); 
    248             } else { 
    249                 $this->printMessage($msg, $this->err, $priority); 
     246            if ($priority != Project::MSG_ERR) { 
     247                $this->printMessage($msg, $this->out, $priority); 
     248            } else { 
     249                $this->printMessage($msg, $this->err, $priority); 
    250250            } 
    251251        } 
    252252    } 
     
    273273     * Prints a message to console. 
    274274     *  
    275275     * @param string $message  The message to print.  
    276      *                 Should not be <code>null</code>. 
     276     *                 Should not be <code>null</code>. 
    277277     * @param resource $stream The stream to use for message printing. 
    278278     * @param int $priority The priority of the message.  
    279279     *                 (Ignored in this implementation.) 
    280280     * @return void 
    281281     */ 
    282     protected function printMessage($message, OutputStream $stream, $priority) { 
     282    protected function printMessage($message, OutputStream $stream, $priority) { 
    283283        $stream->write($message . $this->lSep); 
    284284    }     
    285285} 
  • listener/NoBannerLogger.php

    diff -ru phing-orig/listener/NoBannerLogger.php phing/listener/NoBannerLogger.php
    old new  
    4242                $this->targetName = null; 
    4343        } 
    4444 
    45         function messageLogged(BuildEvent $event) { 
     45        function messageLogged(BuildEvent $event) { 
    4646                 
    4747                if ($event->getPriority() > $this->msgOutputLevel || null === $event->getMessage() || trim($event->getMessage() === "")) { 
    4848                        return; 
    49                 } 
     49                } 
    5050                 
    51                 if ($this->targetName !== null) { 
    52                         $msg = $this->lSep . $event->getProject()->getName() . ' > ' . $this->targetName . ':' . $this->lSep; 
     51                if ($this->targetName !== null) { 
     52                        $msg = $this->lSep . $event->getProject()->getName() . ' > ' . $this->targetName . ':' . $this->lSep; 
    5353                        $this->printMessage($msg, $this->out, $event->getPriority()); 
    5454                        $this->targetName = null; 
    5555                } 
  • listener/PearLogListener.php

    diff -ru phing-orig/listener/PearLogListener.php phing/listener/PearLogListener.php
    old new  
    1919 * <http://phing.info>. 
    2020 */ 
    2121  
    22 require_once 'phing/BuildListener.php'; 
     22require_once 'phing/BuildListener.php'; 
    2323 
    2424/** 
    2525 * Writes build messages to PEAR Log. 
     
    6868     * Whether logging has been configured. 
    6969     * @var boolean 
    7070     */ 
    71     protected $logConfigured = false; 
    72      
    73     /** 
    74      * @var Log PEAR Log object. 
    75      */ 
    76         protected $logger; 
     71    protected $logConfigured = false; 
     72     
     73    /** 
     74     * @var Log PEAR Log object. 
     75     */ 
     76        protected $logger; 
    7777         
    7878    /** 
    7979     * Configure the logger. 
     
    8989        if ($name === null) $name = 'phing.log'; 
    9090        if ($ident === null) $ident = 'phing'; 
    9191        if ($conf === null) $conf = array(); 
    92          
    93         include_once 'Log.php'; 
    94         if (!class_exists('Log')) { 
    95                 throw new BuildException("Cannot find PEAR Log class for use by PearLogger."); 
    96         } 
     92         
     93        include_once 'Log.php'; 
     94        if (!class_exists('Log')) { 
     95                throw new BuildException("Cannot find PEAR Log class for use by PearLogger."); 
     96        } 
    9797         
    9898        $this->logger = Log::singleton($type, $name, $ident, $conf, self::$levelMap[$this->msgOutputLevel]); 
    9999    }         
  • listener/XmlLogger.php

    diff -ru phing-orig/listener/XmlLogger.php phing/listener/XmlLogger.php
    old new  
    2121 
    2222require_once 'phing/BuildLogger.php'; 
    2323require_once 'phing/listener/DefaultLogger.php'; 
    24 require_once 'phing/system/util/Timer.php'; 
     24require_once 'phing/system/util/Timer.php'; 
    2525 
    2626/** 
    2727 * Generates a file in the current directory with 
     
    3333 * @version $Id: XmlLogger.php 147 2007-02-06 20:32:22Z hans $ 
    3434 * @package phing.listener 
    3535 */      
    36 class XmlLogger implements BuildLogger { 
     36class XmlLogger implements BuildLogger { 
    3737         
    3838        /** XML element name for a build. */ 
    3939        const BUILD_TAG = "build"; 
     
    5555        const ERROR_ATTR = "error"; 
    5656        /** XML element name for a stack trace. */ 
    5757        const STACKTRACE_TAG = "stacktrace"; 
    58          
    59         /** 
    60          * @var DOMDocument The XML document created by this logger.  
     58         
     59        /** 
     60         * @var DOMDocument The XML document created by this logger.  
    6161         */ 
    6262        private $doc; 
    6363         
     
    6666        private $taskStartTime = 0; 
    6767         
    6868        private $buildElement; 
    69          
    70         /** 
    71          * @var int 
     69         
     70        /** 
     71         * @var int 
    7272         */ 
    7373        private $msgOutputLevel = Project::MSG_DEBUG; 
    74          
    75         /** 
    76      * @var OutputStream Stream to use for standard output. 
    77      */ 
    78         private $out; 
    79     
    80         /** 
    81          * @var OutputStream Stream to use for error output. 
    82          */ 
    83         private $err; 
     74         
     75        /** 
     76     * @var OutputStream Stream to use for standard output. 
     77     */ 
     78        private $out; 
     79    
     80        /** 
     81         * @var OutputStream Stream to use for error output. 
     82         */ 
     83        private $err; 
    8484         
    8585        /** 
    8686         * @var string Name of filename to create. 
     
    117117         * @param BuildEvent $event An event with any relevant extra information. 
    118118         *              Will not be <code>null</code>. 
    119119         */ 
    120         public function buildFinished(BuildEvent $event) { 
     120        public function buildFinished(BuildEvent $event) { 
    121121                 
    122122                $this->buildTimer->stop(); 
    123123                 
     
    134134                        $stacktrace->appendChild($errText); 
    135135                        $this->buildElement->appendChild($stacktrace); 
    136136                } 
    137                  
    138                 $this->doc->appendChild($this->buildElement); 
    139                  
    140                 $outFilename = $event->getProject()->getProperty("XmlLogger.file"); 
    141         if ($outFilename == null) { 
    142             $outFilename = "log.xml"; 
    143         } 
    144          
    145         try { 
    146                 $stream = $this->out; 
    147                 if ($stream === null) { 
    148                         $stream = new FileOutputStream($outFilename);  
    149                 } 
    150                  
    151                 // Yes, we could just stream->write() but this will eventually be the better 
    152                         // way to do this (when we need to worry about charset conversions.  
    153                 $writer = new OutputStreamWriter($stream); 
    154                 $writer->write($this->doc->saveXML()); 
    155                 $writer->close(); 
    156         } catch (IOException $exc) { 
    157                 try { 
    158                         $stream->close(); // in case there is a stream open still ... 
    159                 } catch (Exception $x) {} 
    160                 throw new BuildException("Unable to write log file.", $exc); 
    161         } 
    162         } 
    163          
     137                 
     138                $this->doc->appendChild($this->buildElement); 
     139                 
     140                $outFilename = $event->getProject()->getProperty("XmlLogger.file"); 
     141        if ($outFilename == null) { 
     142            $outFilename = "log.xml"; 
     143        } 
     144         
     145        try { 
     146                $stream = $this->out; 
     147                if ($stream === null) { 
     148                        $stream = new FileOutputStream($outFilename);  
     149                } 
     150                 
     151                // Yes, we could just stream->write() but this will eventually be the better 
     152                        // way to do this (when we need to worry about charset conversions.  
     153                $writer = new OutputStreamWriter($stream); 
     154                $writer->write($this->doc->saveXML()); 
     155                $writer->close(); 
     156        } catch (IOException $exc) { 
     157                try { 
     158                        $stream->close(); // in case there is a stream open still ... 
     159                } catch (Exception $x) {} 
     160                throw new BuildException("Unable to write log file.", $exc); 
     161        } 
     162        } 
     163         
    164164         
    165165        /** 
    166166         * Fired when a target starts building, remembers the current time and the name of the target. 
     
    188188                $target = $event->getTarget(); 
    189189                $elapsedTime = Phing::currentTimeMillis() - $this->targetTimerStart; 
    190190                $this->targetElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::formatTime($elapsedTime)); 
    191                 $this->buildElement->appendChild($this->targetElement); 
     191                $this->buildElement->appendChild($this->targetElement); 
    192192                $this->targetElement = null; 
    193193        } 
    194194         
     
    204204                $this->taskElement = $this->doc->createElement(XmlLogger::TASK_TAG); 
    205205                $this->taskElement->setAttribute(XmlLogger::NAME_ATTR, $task->getTaskName()); 
    206206                $this->taskElement->setAttribute(XmlLogger::LOCATION_ATTR, $task->getLocation()->toString()); 
    207         } 
     207        } 
    208208         
    209209        /** 
    210210         * Fired when a task finishes building, this adds the time taken 
     
    217217                $task = $event->getTask(); 
    218218                $elapsedTime = Phing::currentTimeMillis() - $this->taskTimerStart; 
    219219                $this->taskElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::formatTime($elapsedTime)); 
    220                 if ($this->targetElement) { // not all tasks are in targets 
    221                         $this->targetElement->appendChild($this->taskElement); 
    222                 } else { 
    223                         $this->buildElement->appendChild($this->taskElement); 
    224                 } 
     220                if ($this->targetElement) { // not all tasks are in targets 
     221                        $this->targetElement->appendChild($this->taskElement); 
     222                } else { 
     223                        $this->buildElement->appendChild($this->taskElement); 
     224                } 
    225225                $this->taskElement = null; 
    226226        } 
    227227         
     
    272272                        $this->buildElement->appendChild($messageElement); 
    273273                } 
    274274        } 
    275  
    276     /** 
    277      *  Set the msgOutputLevel this logger is to respond to. 
    278      * 
    279      *  Only messages with a message level lower than or equal to the given 
    280      *  level are output to the log. 
    281      * 
    282      *  <p> Constants for the message levels are in Project.php. The order of 
    283      *  the levels, from least to most verbose, is: 
    284      * 
    285      *  <ul> 
    286      *    <li>Project::MSG_ERR</li> 
    287      *    <li>Project::MSG_WARN</li> 
    288      *    <li>Project::MSG_INFO</li> 
    289      *    <li>Project::MSG_VERBOSE</li> 
    290      *    <li>Project::MSG_DEBUG</li> 
    291      *  </ul> 
    292      * 
    293      *  The default message level for DefaultLogger is Project::MSG_ERR. 
    294      * 
    295      * @param int $level The logging level for the logger. 
    296      * @see BuildLogger#setMessageOutputLevel() 
    297      */ 
    298     public function setMessageOutputLevel($level) { 
    299         $this->msgOutputLevel = (int) $level; 
    300     } 
    301      
    302     /** 
    303      * Sets the output stream. 
    304      * @param OutputStream $output 
    305      * @see BuildLogger#setOutputStream() 
    306      */ 
    307     public function setOutputStream(OutputStream $output) { 
    308         $this->out = $output; 
    309     } 
    310          
    311     /** 
    312      * Sets the error stream. 
    313      * @param OutputStream $err 
    314      * @see BuildLogger#setErrorStream() 
    315      */ 
    316     public function setErrorStream(OutputStream $err) { 
    317         $this->err = $err; 
    318     } 
     275 
     276    /** 
     277     *  Set the msgOutputLevel this logger is to respond to. 
     278     * 
     279     *  Only messages with a message level lower than or equal to the given 
     280     *  level are output to the log. 
     281     * 
     282     *  <p> Constants for the message levels are in Project.php. The order of 
     283     *  the levels, from least to most verbose, is: 
     284     * 
     285     *  <ul> 
     286     *    <li>Project::MSG_ERR</li> 
     287     *    <li>Project::MSG_WARN</li> 
     288     *    <li>Project::MSG_INFO</li> 
     289     *    <li>Project::MSG_VERBOSE</li> 
     290     *    <li>Project::MSG_DEBUG</li> 
     291     *  </ul> 
     292     * 
     293     *  The default message level for DefaultLogger is Project::MSG_ERR. 
     294     * 
     295     * @param int $level The logging level for the logger. 
     296     * @see BuildLogger#setMessageOutputLevel() 
     297     */ 
     298    public function setMessageOutputLevel($level) { 
     299        $this->msgOutputLevel = (int) $level; 
     300    } 
     301     
     302    /** 
     303     * Sets the output stream. 
     304     * @param OutputStream $output 
     305     * @see BuildLogger#setOutputStream() 
     306     */ 
     307    public function setOutputStream(OutputStream $output) { 
     308        $this->out = $output; 
     309    } 
     310         
     311    /** 
     312     * Sets the error stream. 
     313     * @param OutputStream $err 
     314     * @see BuildLogger#setErrorStream() 
     315     */ 
     316    public function setErrorStream(OutputStream $err) { 
     317        $this->err = $err; 
     318    } 
    319319         
    320320} 
  • system/io/BufferedReader.php

    diff -ru phing-orig/system/io/BufferedReader.php phing/system/io/BufferedReader.php
    old new  
    5353    } 
    5454 
    5555    /** 
    56      * Reads and returns a chunk of data. 
     56     * Reads and returns a chunk of data. 
    5757     * @param int $len Number of bytes to read.  Default is to read configured buffer size number of bytes. 
    5858     * @return mixed buffer or -1 if EOF. 
    5959     */ 
    6060    function read($len = null) { 
    61          
    62         // if $len is specified, we'll use that; otherwise, use the configured buffer size. 
     61         
     62        // if $len is specified, we'll use that; otherwise, use the configured buffer size. 
    6363        if ($len === null) $len = $this->bufferSize;  
    6464         
    6565        if ( ($data = $this->in->read($len)) !== -1 ) { 
  • system/io/BufferedWriter.php

    diff -ru phing-orig/system/io/BufferedWriter.php phing/system/io/BufferedWriter.php
    old new  
    5555     
    5656    public function getResource() { 
    5757        return $this->out->getResource(); 
    58     } 
    59      
    60     public function flush() { 
    61         $this->out->flush(); 
    6258    } 
    63          
    64     /** 
    65      * Close attached stream. 
     59     
     60    public function flush() { 
     61        $this->out->flush(); 
     62    } 
     63         
     64    /** 
     65     * Close attached stream. 
    6666     */ 
    6767    public function close() { 
    6868        return $this->out->close(); 
  • system/io/FileInputStream.php

    diff -ru phing-orig/system/io/FileInputStream.php phing/system/io/FileInputStream.php
    old new  
    1818 * and is licensed under the LGPL. For more information please see 
    1919 * <http://phing.info>. 
    2020 */ 
    21  
    22 require_once 'phing/system/io/InputStream.php'; 
    23 require_once 'phing/system/io/PhingFile.php'; 
     21 
     22require_once 'phing/system/io/InputStream.php'; 
     23require_once 'phing/system/io/PhingFile.php'; 
    2424 
    2525/** 
    26  * Input stream subclass for file streams. 
     26 * Input stream subclass for file streams. 
    2727 *  
    2828 * @package   phing.system.io 
    2929 */ 
    3030class FileInputStream extends InputStream { 
    31          
    32         /** 
    33          * @var PhingFile The associated file. 
    34          */ 
    35         protected $file; 
     31         
     32        /** 
     33         * @var PhingFile The associated file. 
     34         */ 
     35        protected $file; 
    3636         
    3737    /** 
    3838     * Construct a new FileInputStream. 
    39      * @param mixed $file 
    40      * @throws Exception - if invalid argument specified. 
     39     * @param mixed $file 
     40     * @throws Exception - if invalid argument specified. 
    4141     * @throws IOException - if unable to open file. 
    4242     */ 
    43     public function __construct($file, $append = false) { 
    44         if ($file instanceof PhingFile) { 
    45             $this->file = $file; 
    46         } elseif (is_string($file)) { 
    47             $this->file = new PhingFile($file); 
    48         } else { 
    49             throw new Exception("Invalid argument type for \$file."); 
    50         } 
    51          
    52         $stream = @fopen($this->file->getAbsolutePath(), "rb"); 
    53         if ($stream === false) { 
    54                 throw new IOException("Unable to open " . $this->file->__toString() . " for reading: " . $php_errormsg); 
    55         } 
    56          
     43    public function __construct($file, $append = false) { 
     44        if ($file instanceof PhingFile) { 
     45            $this->file = $file; 
     46        } elseif (is_string($file)) { 
     47            $this->file = new PhingFile($file); 
     48        } else { 
     49            throw new Exception("Invalid argument type for \$file."); 
     50        } 
     51         
     52        $stream = @fopen($this->file->getAbsolutePath(), "rb"); 
     53        if ($stream === false) { 
     54                throw new IOException("Unable to open " . $this->file->__toString() . " for reading: " . $php_errormsg); 
     55        } 
     56         
    5757        parent::__construct($stream); 
    5858    } 
    59      
    60     /** 
    61      * Returns a string representation of the attached file. 
    62      * @return string 
     59     
     60    /** 
     61     * Returns a string representation of the attached file. 
     62     * @return string 
    6363     */ 
    6464    public function __toString() { 
    6565        return $this->file->getPath(); 
    66     } 
    67      
    68     /** 
    69      * Mark is supported by FileInputStream. 
    70      * @return boolean TRUE 
    71      */ 
    72         public function markSupported() { 
    73         return true; 
     66    } 
     67     
     68    /** 
     69     * Mark is supported by FileInputStream. 
     70     * @return boolean TRUE 
     71     */ 
     72        public function markSupported() { 
     73        return true; 
    7474    } 
    7575} 
    7676 
  • system/io/FileOutputStream.php

    diff -ru phing-orig/system/io/FileOutputStream.php phing/system/io/FileOutputStream.php
    old new  
    1818 * and is licensed under the LGPL. For more information please see 
    1919 * <http://phing.info>. 
    2020 */ 
    21  
    22 require_once 'phing/system/io/OutputStream.php'; 
    23 require_once 'phing/system/io/PhingFile.php'; 
     21 
     22require_once 'phing/system/io/OutputStream.php'; 
     23require_once 'phing/system/io/PhingFile.php'; 
    2424 
    2525/** 
    26  * Output stream subclass for file streams. 
     26 * Output stream subclass for file streams. 
    2727 *  
    2828 * @package   phing.system.io 
    2929 */ 
    3030class FileOutputStream extends OutputStream { 
    31          
    32         /** 
    33          * @var PhingFile The associated file. 
    34          */ 
    35         protected $file; 
     31         
     32        /** 
     33         * @var PhingFile The associated file. 
     34         */ 
     35        protected $file; 
    3636         
    3737    /** 
    3838     * Construct a new FileOutputStream. 
    39      * @param mixed $file 
    40      * @param boolean $append Whether to append bytes to end of file rather than beginning. 
    41      * @throws Exception - if invalid argument specified. 
     39     * @param mixed $file 
     40     * @param boolean $append Whether to append bytes to end of file rather than beginning. 
     41     * @throws Exception - if invalid argument specified. 
    4242     * @throws IOException - if unable to open file. 
    4343     */ 
    44     public function __construct($file, $append = false) { 
    45         if ($file instanceof PhingFile) { 
    46             $this->file = $file; 
    47         } elseif (is_string($file)) { 
    48             $this->file = new PhingFile($file); 
    49         } else { 
    50             throw new Exception("Invalid argument type for \$file."); 
    51         } 
    52         if ($append) { 
    53                 $stream = @fopen($this->file->getAbsolutePath(), "ab"); 
    54         } else { 
    55                 $stream = @fopen($this->file->getAbsolutePath(), "wb"); 
    56         } 
    57         if ($stream === false) { 
    58                 throw new IOException("Unable to open " . $this->file->__toString() . " for writing: " . $php_errormsg); 
    59         } 
     44    public function __construct($file, $append = false) { 
     45        if ($file instanceof PhingFile) { 
     46            $this->file = $file; 
     47        } elseif (is_string($file)) { 
     48            $this->file = new PhingFile($file); 
     49        } else { 
     50            throw new Exception("Invalid argument type for \$file."); 
     51        } 
     52        if ($append) { 
     53                $stream = @fopen($this->file->getAbsolutePath(), "ab"); 
     54        } else { 
     55                $stream = @fopen($this->file->getAbsolutePath(), "wb"); 
     56        } 
     57        if ($stream === false) { 
     58                throw new IOException("Unable to open " . $this->file->__toString() . " for writing: " . $php_errormsg); 
     59        } 
    6060        parent::__construct($stream); 
    6161    } 
    62      
    63     /** 
    64      * Returns a string representation of the attached file. 
    65      * @return string 
     62     
     63    /** 
     64     * Returns a string representation of the attached file. 
     65     * @return string 
    6666     */ 
    6767    public function __toString() { 
    6868        return $this->file->getPath(); 
  • system/io/FileReader.php

    diff -ru phing-orig/system/io/FileReader.php phing/system/io/FileReader.php
    old new  
    2020 */ 
    2121 
    2222require_once 'phing/system/io/InputStreamReader.php'; 
    23 require_once 'phing/system/io/FileInputStream.php'; 
     23require_once 'phing/system/io/FileInputStream.php'; 
    2424 
    2525/** 
    2626 * Convenience class for reading files. 
     
    2828 */ 
    2929class FileReader extends InputStreamReader { 
    3030 
    31         /** 
    32      * Construct a new FileReader. 
    33      * @param mixed $file PhingFile or string pathname. 
    34      */ 
    35     public function __construct($file) { 
    36         $in = new FileInputStream($file); 
    37         parent::__construct($in); 
    38     } 
    39          
     31        /** 
     32     * Construct a new FileReader. 
     33     * @param mixed $file PhingFile or string pathname. 
     34     */ 
     35    public function __construct($file) { 
     36        $in = new FileInputStream($file); 
     37        parent::__construct($in); 
     38    } 
     39         
    4040} 
    4141 
  • system/io/FileSystem.php

    diff -ru phing-orig/system/io/FileSystem.php phing/system/io/FileSystem.php
    old new  
    5151     
    5252    /** 
    5353     * Static method to return the FileSystem singelton representing 
    54      * this platform's local filesystem driver. 
     54     * this platform's local filesystem driver. 
    5555     * @return FileSystem 
    5656     */ 
    5757    public static function getFileSystem() { 
  • system/io/FileWriter.php

    diff -ru phing-orig/system/io/FileWriter.php phing/system/io/FileWriter.php
    old new  
    2020 */ 
    2121 
    2222require_once 'phing/system/io/OutputStreamWriter.php'; 
    23 require_once 'phing/system/io/FileOutputStream.php'; 
     23require_once 'phing/system/io/FileOutputStream.php'; 
    2424 
    2525/** 
    2626 * Convenience class for performing file write operations. 
     
    3434     * @param mixed $file PhingFile or string pathname. 
    3535     * @param boolean $append Append to existing file? 
    3636     */ 
    37     function __construct($file, $append = false) { 
    38         $out = new FileOutputStream($file, $append); 
     37    function __construct($file, $append = false) { 
     38        $out = new FileOutputStream($file, $append); 
    3939        parent::__construct($out); 
    4040    } 
    4141} 
  • system/io/FilterReader.php

    diff -ru phing-orig/system/io/FilterReader.php phing/system/io/FilterReader.php
    old new  
    2626 * @package phing.system.io 
    2727 */ 
    2828class FilterReader extends Reader { 
    29      
    30         /**  
    31          * @var Reader 
     29     
     30        /**  
     31         * @var Reader 
    3232         */ 
    3333    protected $in; 
    3434     
     
    5959     
    6060    public function close() { 
    6161        return $this->in->close(); 
    62     } 
     62    } 
    6363     
    6464    function getResource() { 
    6565        return $this->in->getResource(); 
  • system/io/InputStream.php

    diff -ru phing-orig/system/io/InputStream.php phing/system/io/InputStream.php
    old new  
    2020 */ 
    2121 
    2222/** 
    23  * Wrapper class for PHP stream that supports read operations. 
     23 * Wrapper class for PHP stream that supports read operations. 
    2424 *  
    2525 * @package   phing.system.io 
    2626 */ 
    2727class InputStream { 
    28          
    29         /** 
    30          * @var resource The attached PHP stream. 
    31          */ 
    32         protected $stream; 
    33          
    34         /** 
    35          * @var int Position of stream cursor. 
     28         
     29        /** 
     30         * @var resource The attached PHP stream. 
    3631         */ 
    37     protected $currentPosition = 0; 
    38      
    39     /** 
    40      * @var int Marked position of stream cursor. 
     32        protected $stream; 
     33         
     34        /** 
     35         * @var int Position of stream cursor. 
     36         */ 
     37    protected $currentPosition = 0; 
     38     
     39    /** 
     40     * @var int Marked position of stream cursor. 
    4141     */ 
    4242    protected $mark = 0; 
    43          
    44         /** 
    45      * Construct a new InputStream. 
    46      * @param resource $stream Configured PHP stream for writing. 
    47      */ 
    48     public function __construct($stream) { 
    49         if (!is_resource($stream)) { 
    50                 throw new IOException("Passed argument is not a valid stream."); 
    51         } 
    52         $this->stream = $stream; 
    53     } 
    54  
    55     /** 
    56      * Skip over $n bytes. 
    57      * @param int $n 
     43         
     44        /** 
     45     * Construct a new InputStream. 
     46     * @param resource $stream Configured PHP stream for writing. 
     47     */ 
     48    public function __construct($stream) { 
     49        if (!is_resource($stream)) { 
     50                throw new IOException("Passed argument is not a valid stream."); 
     51        } 
     52        $this->stream = $stream; 
     53    } 
     54 
     55    /** 
     56     * Skip over $n bytes. 
     57     * @param int $n 
    5858     */ 
    5959    public function skip($n) { 
    6060        $start = $this->currentPosition; 
     
    7878     * @param int $len Num chars to read.  If not specified this stream will read until EOF. 
    7979     * @return string chars read or -1 if eof. 
    8080     */ 
    81     public function read($len = null) { 
     81    public function read($len = null) { 
    8282         
    8383        if ($this->eof()) { 
    8484            return -1; 
    85         } 
    86          
    87         if ($len === null) { // we want to keep reading until we get an eof 
    88                         $out = ""; 
    89                 while(!$this->eof()) { 
    90                         $out .= fread($this->stream, 8192); 
    91                         $this->currentPosition = ftell($this->stream); 
    92                 } 
    93         } else { 
    94                         $out = fread($this->stream, $len); // adding 1 seems to ensure that next call to read() will return EOF (-1) 
    95                 $this->currentPosition = ftell($this->stream); 
     85        } 
     86         
     87        if ($len === null) { // we want to keep reading until we get an eof 
     88                        $out = ""; 
     89                while(!$this->eof()) { 
     90                        $out .= fread($this->stream, 8192); 
     91                        $this->currentPosition = ftell($this->stream); 
     92                } 
     93        } else { 
     94                        $out = fread($this->stream, $len); // adding 1 seems to ensure that next call to read() will return EOF (-1) 
     95                $this->currentPosition = ftell($this->stream); 
    9696        } 
    9797 
    9898        return $out; 
    9999    }     
    100      
    101     /** 
    102      * Marks the current position in this input stream. 
    103      * @throws IOException - if the underlying stream doesn't support this method. 
    104      */ 
    105     public function mark() { 
    106         if (!$this->markSupported()) { 
    107                 throw new IOException(get_class($this) . " does not support mark() and reset() methods."); 
     100     
     101    /** 
     102     * Marks the current position in this input stream. 
     103     * @throws IOException - if the underlying stream doesn't support this method. 
     104     */ 
     105    public function mark() { 
     106        if (!$this->markSupported()) { 
     107                throw new IOException(get_class($this) . " does not support mark() and reset() methods."); 
    108108        } 
    109109        $this->mark = $this->currentPosition; 
    110     } 
    111      
    112     /** 
    113      * Whether the input stream supports mark and reset methods. 
    114      * @return boolean 
    115      */ 
    116     public function markSupported() { 
    117         return false; 
    118     } 
    119      
    120     /** 
    121      * Repositions this stream to the position at the time the mark method was last called on this input stream. 
    122      * @throws IOException - if the underlying stream doesn't support this method. 
    123      */ 
    124     function reset() { 
    125         if (!$this->markSupported()) { 
    126                 throw new IOException(get_class($this) . " does not support mark() and reset() methods."); 
     110    } 
     111     
     112    /** 
     113     * Whether the input stream supports mark and reset methods. 
     114     * @return boolean 
     115     */ 
     116    public function markSupported() { 
     117        return false; 
     118    } 
     119     
     120    /** 
     121     * Repositions this stream to the position at the time the mark method was last called on this input stream. 
     122     * @throws IOException - if the underlying stream doesn't support this method. 
     123     */ 
     124    function reset() { 
     125        if (!$this->markSupported()) { 
     126                throw new IOException(get_class($this) . " does not support mark() and reset() methods."); 
    127127        } 
    128128        // goes back to last mark, by default this would be 0 (i.e. rewind file). 
    129129        fseek($this->stream, SEEK_SET, $this->mark); 
    130130        $this->mark = 0; 
    131131    } 
    132          
    133     /** 
    134      * Closes stream. 
    135      * @throws IOException if stream cannot be closed (note that calling close() on an already-closed stream will not raise an exception) 
     132         
     133    /** 
     134     * Closes stream. 
     135     * @throws IOException if stream cannot be closed (note that calling close() on an already-closed stream will not raise an exception) 
    136136     */ 
    137137    public function close() { 
    138138        if ($this->stream === null) { 
     
    144144            throw new IOException($msg); 
    145145        } 
    146146        $this->stream = null; 
    147     } 
     147    } 
    148148     
    149149    /** 
    150150     * Whether eof has been reached with stream. 
     
    159159     * 
    160160     * @param string &$rBuffer String variable where read contents will be put. 
    161161     * @return TRUE on success. 
    162      * @author  Charlie Killian, charlie@tizac.com 
    163      * @throws IOException - if there is an error reading from stream. 
     162     * @author  Charlie Killian, charlie@tizac.com 
     163     * @throws IOException - if there is an error reading from stream. 
    164164     * @deprecated - Instead, use the read() method or a BufferedReader. 
    165165     */ 
    166166    public function readInto(&$rBuffer) { 
    167                 $rBuffer = $this->read(); 
     167                $rBuffer = $this->read(); 
    168168                $this->close(); 
    169169    } 
    170170     
  • system/io/InputStreamReader.php

    diff -ru phing-orig/system/io/InputStreamReader.php phing/system/io/InputStreamReader.php
    old new  
    2323include_once 'phing/system/io/Reader.php'; 
    2424 
    2525/** 
    26  * Writer class for OutputStream objects. 
    27  *  
    28  * Unlike the Java counterpart, this class does not (yet) handle 
    29  * character set transformations.  This will be an important function 
    30  * of this class with move to supporting PHP6. 
     26 * Writer class for OutputStream objects. 
     27 *  
     28 * Unlike the Java counterpart, this class does not (yet) handle 
     29 * character set transformations.  This will be an important function 
     30 * of this class with move to supporting PHP6. 
    3131 *  * @package   phing.system.io 
    3232 */ 
    3333class InputStreamReader extends Reader { 
    34          
    35         /** 
    36          * @var InputStream 
    37          */ 
    38         protected $inStream; 
    3934         
    40         /** 
    41      * Construct a new InputStreamReader. 
    42      * @param InputStream $$inStream InputStream to read from 
    43      */ 
    44     public function __construct(InputStream $inStream) { 
    45         $this->inStream = $inStream; 
    46     } 
    47          
    48     /** 
    49      * Close the stream. 
    50      */ 
    51     public function close() { 
    52         return $this->inStream->close(); 
    53     } 
    54          
    55     /** 
    56      * Skip over $n bytes. 
    57      * @param int $n 
     35        /** 
     36         * @var InputStream 
     37         */ 
     38        protected $inStream; 
     39         
     40        /** 
     41     * Construct a new InputStreamReader. 
     42     * @param InputStream $$inStream InputStream to read from 
     43     */ 
     44    public function __construct(InputStream $inStream) { 
     45        $this->inStream = $inStream; 
     46    } 
     47         
     48    /** 
     49     * Close the stream. 
     50     */ 
     51    public function close() { 
     52        return $this->inStream->close(); 
     53    } 
     54         
     55    /** 
     56     * Skip over $n bytes. 
     57     * @param int $n 
    5858     */ 
    59     public function skip($n) { 
     59    public function skip($n) { 
    6060        return $this->inStream->skip($n); 
    6161    } 
    6262     
     
    6565     * @param int $len Num chars to read. 
    6666     * @return string chars read or -1 if eof. 
    6767     */ 
    68     public function read($len = null) { 
     68    public function read($len = null) { 
    6969        return $this->inStream->read($len); 
    7070    } 
    71      
    72     /** 
    73      * Marks the current position in this input stream. 
    74      * @throws IOException - if the underlying stream doesn't support this method. 
     71     
     72    /** 
     73     * Marks the current position in this input stream. 
     74     * @throws IOException - if the underlying stream doesn't support this method. 
    7575     */ 
    7676    public function mark() { 
    7777        $this->inStream->mark(); 
    78     } 
    79      
    80     /** 
    81      * Whether the attached stream supports mark/reset. 
    82      * @return boolean 
    83      */ 
    84     public function markSupported() { 
    85         return $this->inStream->markSupported(); 
    86     } 
     78    } 
    8779     
    88     /** 
    89      * Repositions this stream to the position at the time the mark method was last called on this input stream. 
    90      * @throws IOException - if the underlying stream doesn't support this method. 
     80    /** 
     81     * Whether the attached stream supports mark/reset. 
     82     * @return boolean 
     83     */ 
     84    public function markSupported() { 
     85        return $this->inStream->markSupported(); 
     86    } 
     87     
     88    /** 
     89     * Repositions this stream to the position at the time the mark method was last called on this input stream. 
     90     * @throws IOException - if the underlying stream doesn't support this method. 
    9191     */ 
    9292    public function reset() { 
    9393        $this->inStream->reset(); 
     
    109109     * @param    object &$rBuffer    Reference. Variable of where to put contents. 
    110110     * 
    111111     * @return    TRUE on success. Err object on failure. 
    112      * @author  Charlie Killian, charlie@tizac.com 
     112     * @author  Charlie Killian, charlie@tizac.com 
    113113     * @deprecated Use read() or BufferedReader instead. 
    114114     */ 
    115115    public function readInto(&$rBuffer) { 
  • system/io/OutputStream.php

    diff -ru phing-orig/system/io/OutputStream.php phing/system/io/OutputStream.php
    old new  
    2020 */ 
    2121 
    2222/** 
    23  * Wrapper class for PHP stream that supports write operations. 
     23 * Wrapper class for PHP stream that supports write operations. 
    2424 *  
    2525 * @package   phing.system.io 
    2626 */ 
    2727class OutputStream { 
    28          
    29         /** 
    30          * @var resource The configured PHP stream. 
     28         
     29        /** 
     30         * @var resource The configured PHP stream. 
    3131         */ 
    3232    protected $stream; 
    3333 
     
    3535     * Construct a new OutputStream. 
    3636     * @param resource $stream Configured PHP stream for writing. 
    3737     */ 
    38     public function __construct($stream) { 
    39         if (!is_resource($stream)) { 
    40                 throw new IOException("Passed argument is not a valid stream."); 
    41         } 
     38    public function __construct($stream) { 
     39        if (!is_resource($stream)) { 
     40                throw new IOException("Passed argument is not a valid stream."); 
     41        } 
    4242        $this->stream = $stream; 
    4343    } 
    44          
    45     /** 
    46      * Closes attached stream, flushing output first. 
    47      * @throws IOException if cannot close stream (note that attempting to close an already closed stream will not raise an IOException) 
    48      * @return void 
     44         
     45    /** 
     46     * Closes attached stream, flushing output first. 
     47     * @throws IOException if cannot close stream (note that attempting to close an already closed stream will not raise an IOException) 
     48     * @return void 
    4949     */ 
    50     public function close() { 
    51         if ($this->stream === null) { 
    52             return; 
    53         } 
    54         $this->flush(); 
    55         if (false === @fclose($this->stream)) { 
    56             $msg = "Cannot close " . $this->getResource() . ": $php_errormsg"; 
    57             throw new IOException($msg); 
    58         } 
     50    public function close() { 
     51        if ($this->stream === null) { 
     52            return; 
     53        } 
     54        $this->flush(); 
     55        if (false === @fclose($this->stream)) { 
     56            $msg = "Cannot close " . $this->getResource() . ": $php_errormsg"; 
     57            throw new IOException($msg); 
     58        } 
    5959                $this->stream = null; 
    6060        } 
    61      
    62         /** 
    63      * Flushes stream. 
    64      *  
    65      * @throws IOException if unable to flush data (e.g. stream is not open). 
    66      */ 
    67     public function flush() { 
    68         if (false === @fflush($this->stream)) { 
    69                 throw new IOException("Could not flush stream: " . $php_errormsg); 
    70         } 
     61     
     62        /** 
     63     * Flushes stream. 
     64     *  
     65     * @throws IOException if unable to flush data (e.g. stream is not open). 
     66     */ 
     67    public function flush() { 
     68        if (false === @fflush($this->stream)) { 
     69                throw new IOException("Could not flush stream: " . $php_errormsg); 
     70        } 
    7171        } 
    72          
    73     /** 
    74      * Writes data to stream. 
    75      * 
    76      * @param string $buf Binary/character data to write. 
    77      * @param int $off (Optional) offset. 
    78      * @param int $len (Optional) number of bytes/chars to write.  
    79      * @return void 
    80      * @throws IOException - if there is an error writing to stream 
     72         
     73    /** 
     74     * Writes data to stream. 
     75     * 
     76     * @param string $buf Binary/character data to write. 
     77     * @param int $off (Optional) offset. 
     78     * @param int $len (Optional) number of bytes/chars to write.  
     79     * @return void 
     80     * @throws IOException - if there is an error writing to stream 
    8181     */ 
    8282    public function write($buf, $off = null, $len = null) { 
    8383        if ( $off === null && $len === null ) { 
    84             $to_write = $buf; 
    85         } elseif ($off !== null && $len === null) { 
     84            $to_write = $buf; 
     85        } elseif ($off !== null && $len === null) { 
    8686                $to_write = substr($buf, $off); 
    8787        } elseif ($off === null && $len !== null) { 
    88             $to_write = substr($buf, 0, $len); 
    89         } else { 
    90                 $to_write = substr($buf, $off, $len); 
    91         } 
     88            $to_write = substr($buf, 0, $len); 
     89        } else { 
     90                $to_write = substr($buf, $off, $len); 
     91        } 
    9292         
    9393        $result = @fwrite($this->stream, $to_write); 
    9494 
     
    9696            throw new IOException("Error writing to stream."); 
    9797        } 
    9898    } 
    99      
    100     /** 
    101      * Returns a string representation of the attached PHP stream. 
    102      * @return string 
     99     
     100    /** 
     101     * Returns a string representation of the attached PHP stream. 
     102     * @return string 
    103103     */ 
    104104    public function __toString() { 
    105105        return (string) $this->stream; 
  • system/io/OutputStreamWriter.php

    diff -ru phing-orig/system/io/OutputStreamWriter.php phing/system/io/OutputStreamWriter.php
    old new  
    2323require_once 'phing/system/io/Writer.php'; 
    2424 
    2525/** 
    26  * Writer class for OutputStream objects. 
    27  *  
    28  * Unlike the Java counterpart, this class does not (yet) handle 
    29  * character set transformations.  This will be an important function 
     26 * Writer class for OutputStream objects. 
     27 *  
     28 * Unlike the Java counterpart, this class does not (yet) handle 
     29 * character set transformations.  This will be an important function 
    3030 * of this class with move to supporting PHP6. 
    3131 * 
    3232 * @package   phing.system.io 
    3333 */ 
    3434class OutputStreamWriter extends Writer { 
    35  
    36         /** 
    37          * @var OutputStream 
     35 
     36        /** 
     37         * @var OutputStream 
    3838         */ 
    3939    protected $outStream; 
    4040     
     
    4545    public function __construct(OutputStream $outStream) { 
    4646        $this->outStream = $outStream; 
    4747    } 
    48          
    49     /** 
    50      * Close the stream. 
     48         
     49    /** 
     50     * Close the stream. 
    5151     */ 
    52     public function close() { 
     52    public function close() { 
    5353        return $this->outStream->close(); 
    5454    } 
    55          
    56     /** 
    57      * Write char data to stream. 
    58      * 
    59      * @param unknown_type $buf 
    60      * @param unknown_type $off 
    61      * @param unknown_type $len 
    62      * @return unknown 
     55         
     56    /** 
     57     * Write char data to stream. 
     58     * 
     59     * @param unknown_type $buf 
     60     * @param unknown_type $off 
     61     * @param unknown_type $len 
     62     * @return unknown 
    6363     */ 
    64     public function write($buf, $off = null, $len = null) { 
     64    public function write($buf, $off = null, $len = null) { 
    6565        return $this->outStream->write($buf, $off, $len); 
    66     } 
    67      
    68     /** 
    69      * Flush output to the stream. 
    70      */ 
    71         public function flush() { 
    72         $this->outStream->flush(); 
    7366    } 
    74      
    75     /** 
    76      * Gets a string representation of attached stream resource. 
    77      * 
    78      * @return string String representation of output stream 
     67     
     68    /** 
     69     * Flush output to the stream. 
     70     */ 
     71        public function flush() { 
     72        $this->outStream->flush(); 
     73    } 
     74     
     75    /** 
     76     * Gets a string representation of attached stream resource. 
     77     * 
     78     * @return string String representation of output stream 
    7979     */ 
    80     public function getResource() { 
     80    public function getResource() { 
    8181        return $this->outStream->__toString(); 
    8282    } 
    8383} 
  • system/io/Reader.php

    diff -ru phing-orig/system/io/Reader.php phing/system/io/Reader.php
    old new  
    2020*/ 
    2121 
    2222/** 
    23  * Abstract class for reading character streams. 
     23 * Abstract class for reading character streams. 
    2424 *  
    2525 * @author Hans Lellelid <hans@xmpl.org> 
    2626 * @author Yannick Lecaillez <yl@seasonfive.com> 
     
    3030abstract class Reader { 
    3131 
    3232    /** 
    33      * Read data from source. 
     33     * Read data from source. 
    3434     *  
    3535     * If length is specified, then only that number of chars is read, 
    36      * otherwise stream is read until EOF. 
     36     * otherwise stream is read until EOF. 
    3737     *  
    3838     * @param int $len 
    3939     */ 
    4040    abstract public function read($len = null); 
    4141             
    4242    /** 
    43      * Close stream. 
     43     * Close stream. 
    4444     * @throws IOException if there is an error closing stream 
    4545     */ 
    4646    abstract public function close(); 
     
    7575     * Whether marking is supported. 
    7676     * @return boolean 
    7777     */ 
    78     public function markSupported() { 
    79         return false; 
     78    public function markSupported() { 
     79        return false; 
    8080    } 
    8181     
    8282    /** 
    8383     * Is stream ready for reading. 
    8484     * @return boolean 
    8585     */ 
    86     public function ready() { 
    87         return true; 
     86    public function ready() { 
     87        return true; 
    8888    } 
    8989 
    9090} 
  • system/io/StringReader.php

    diff -ru phing-orig/system/io/StringReader.php phing/system/io/StringReader.php
    old new  
    2424 * @package phing.system.io 
    2525 */ 
    2626class StringReader extends Reader { 
    27      
    28         /** 
    29          * @var string 
     27     
     28        /** 
     29         * @var string 
    3030         */ 
    31     private $_string; 
    32      
    33     /** 
    34      * @var int 
     31    private $_string; 
     32     
     33    /** 
     34     * @var int 
    3535     */ 
    36     private $mark = 0; 
    37      
    38     /** 
    39      * @var int 
     36    private $mark = 0; 
     37     
     38    /** 
     39     * @var int 
    4040     */ 
    4141    private $currPos = 0; 
    4242     
  • system/io/Writer.php

    diff -ru phing-orig/system/io/Writer.php phing/system/io/Writer.php
    old new  
    2020 */ 
    2121 
    2222/** 
    23  * Abstract class for writing character streams. 
     23 * Abstract class for writing character streams. 
    2424 *  
    2525 * @package   phing.system.io 
    2626 */ 
    2727abstract class Writer { 
    28          
    29         /** 
    30          * Writes data to output stream. 
    31          * @param string $buf 
    32          * @param int $off 
    33          * @param int $len 
     28         
     29        /** 
     30         * Writes data to output stream. 
     31         * @param string $buf 
     32         * @param int $off 
     33         * @param int $len 
    3434         */ 
    3535    abstract public function write($buf, $off = null, $len = null); 
    36      
    37     /** 
    38      * Close the stream. 
    39      * @throws IOException - if there is an error closing stream. 
     36     
     37    /** 
     38     * Close the stream. 
     39     * @throws IOException - if there is an error closing stream. 
    4040     */ 
    4141    abstract public function close(); 
    42          
    43     /** 
    44      * Flush the stream, if supported by the stream. 
    45      */ 
     42         
     43    /** 
     44     * Flush the stream, if supported by the stream. 
     45     */ 
    4646    public function flush() {} 
    4747     
    4848    /** 
  • tasks/ext/ioncube/IoncubeComment.php

    diff -ru phing-orig/tasks/ext/ioncube/IoncubeComment.php phing/tasks/ext/ioncube/IoncubeComment.php
    old new  
    1 <?php 
    2 /** 
    3  * $Id: IoncubeComment.php 81 2006-07-06 13:07:29Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 /** 
    23  * Wrapper for comments for ionCube tasks 
    24  * 
    25  * @author Michiel Rook <michiel.rook@gmail.com> 
    26  * @version $Id: IoncubeComment.php 81 2006-07-06 13:07:29Z mrook $ 
    27  * @package phing.tasks.ext.ioncube 
    28  * @since 2.2.0 
    29  */ 
    30 class IoncubeComment 
    31 { 
    32         private $value = ""; 
    33          
    34         public function getValue() 
    35         { 
    36                 return $this->value; 
    37         } 
    38          
    39         public function addText($txt) 
    40         { 
    41                 $this->value = trim($txt); 
    42         } 
    43 } 
     1<?php 
     2/** 
     3 * $Id: IoncubeComment.php 81 2006-07-06 13:07:29Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22/** 
     23 * Wrapper for comments for ionCube tasks 
     24 * 
     25 * @author Michiel Rook <michiel.rook@gmail.com> 
     26 * @version $Id: IoncubeComment.php 81 2006-07-06 13:07:29Z mrook $ 
     27 * @package phing.tasks.ext.ioncube 
     28 * @since 2.2.0 
     29 */ 
     30class IoncubeComment 
     31{ 
     32        private $value = ""; 
     33         
     34        public function getValue() 
     35        { 
     36                return $this->value; 
     37        } 
     38         
     39        public function addText($txt) 
     40        { 
     41                $this->value = trim($txt); 
     42        } 
     43} 
    4444?> 
     45 No newline at end of file 
  • tasks/ext/ScpSendTask.php

    diff -ru phing-orig/tasks/ext/ScpSendTask.php phing/tasks/ext/ScpSendTask.php
    old new  
    1 <?php 
    2 /** 
    3  * $Id: ScpSendTask.php 123 2006-09-14 20:19:08Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 require_once 'phing/Task.php'; 
    23  
    24 /** 
    25  * SCPs a File to a remote server  
    26  * 
    27  * @author Andrew Eddie <andrew.eddie@jamboworks.com>  
    28  * @version $Id: ScpSendTask.php 123 2006-09-14 20:19:08Z mrook $ 
    29  * @package phing.tasks.ext 
    30  * @since 2.3.0 
    31  */ 
    32 class ScpSendTask extends Task 
    33 { 
    34         private $localFile = ""; 
    35  
    36         private $remoteFile = ""; 
    37  
    38         private $username = ""; 
    39  
    40         private $password = ""; 
    41  
    42         private $host = ""; 
    43  
    44         private $port = 22; 
    45  
    46         private $mode = null; 
    47  
    48         private $_connection = null; 
    49  
    50         /** 
    51          * Sets the remote host 
    52          */ 
    53         function setHost($h) 
    54         { 
    55                 $this->host = $h; 
    56         } 
    57  
    58         /** 
    59          * Returns the remote host 
    60          */ 
    61         function getHost() 
    62         { 
    63                 return $this->host; 
    64         } 
    65  
    66         /** 
    67          * Sets the remote host port 
    68          */ 
    69         function setPort($p) 
    70         { 
    71                 $this->port = $p; 
    72         } 
    73  
    74         /** 
    75          * Returns the remote host port 
    76          */ 
    77         function getPort() 
    78         { 
    79                 return $this->port; 
    80         } 
    81  
    82         /** 
    83          * Sets the mode value 
    84          */ 
    85         function setMode($value) 
    86         { 
    87                 $this->mode = $value; 
    88         } 
    89  
    90         /** 
    91          * Returns the mode value 
    92          */ 
    93         function getMode() 
    94         { 
    95                 return $this->mode; 
    96         } 
    97  
    98         /** 
    99          * Sets the username of the user to scp 
    100          */ 
    101         function setUsername($username) 
    102         { 
    103                 $this->username = $username; 
    104         } 
    105  
    106         /** 
    107          * Returns the username 
    108          */ 
    109         function getUsername() 
    110         { 
    111                 return $this->username; 
    112         } 
    113  
    114         /** 
    115          * Sets the password of the user to scp 
    116          */ 
    117         function setPassword($password) 
    118         { 
    119                 $this->password = $password; 
    120         } 
    121  
    122         /** 
    123          * Returns the password 
    124          */ 
    125         function getPassword() 
    126         { 
    127                 return $this->password; 
    128         } 
    129  
    130         /** 
    131          * Sets the local path to scp from 
    132          */ 
    133         function setLocalFile($lFile) 
    134         { 
    135                 $this->localFile = $lFile; 
    136         } 
    137  
    138         /** 
    139          * Returns the local path to scp from 
    140          */ 
    141         function getLocalFile($lFile) 
    142         { 
    143                 return $this->localFile; 
    144         } 
    145  
    146         /** 
    147          * Sets the remote path to scp to 
    148          */ 
    149         function setRemoteFile($rFile) 
    150         { 
    151                 $this->remoteFile = $rFile; 
    152         } 
    153  
    154         /** 
    155          * Returns the remote path to scp to 
    156          */ 
    157         function getRemoteFile($rFile) 
    158         { 
    159                 return $this->remoteFile; 
    160         } 
    161  
    162         /** 
    163         * The init method: Do init steps. 
    164         */ 
    165         public function init() 
    166         { 
    167                 if (function_exists('ssh2_connect')) { 
    168                         $this->_connection = ssh2_connect($this->host, $this->port); 
    169                         ssh2_auth_password($this->_connection, $this->username, $this->password); 
    170                 } else { 
    171                         print ("ERROR: SSH Extension is not installed"); 
    172                 } 
    173         } 
    174  
    175         /** 
    176          * The main entry point method. 
    177          */ 
    178         public function main() 
    179         { 
    180                 if (function_exists('ssh2_scp_send') && !is_null($this->_connection)) 
    181                 { 
    182                         if (!is_null($this->mode)) { 
    183                                 ssh2_scp_send($this->_connection, $this->localFile, $this->remoteFile, $this->mode); 
    184                         } else { 
    185                                 ssh2_scp_send($this->_connection, $this->localFile, $this->remoteFile); 
    186                         } 
    187                 } else { 
    188                         print ("ERROR: No SSH Connection Available"); 
    189                 } 
    190         } 
    191 } 
    192 ?> 
     1<?php 
     2/** 
     3 * $Id: ScpSendTask.php 123 2006-09-14 20:19:08Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22require_once 'phing/Task.php'; 
     23 
     24/** 
     25 * SCPs a File to a remote server  
     26 * 
     27 * @author Andrew Eddie <andrew.eddie@jamboworks.com>  
     28 * @version $Id: ScpSendTask.php 123 2006-09-14 20:19:08Z mrook $ 
     29 * @package phing.tasks.ext 
     30 * @since 2.3.0 
     31 */ 
     32class ScpSendTask extends Task 
     33{ 
     34        private $localFile = ""; 
     35 
     36        private $remoteFile = ""; 
     37 
     38        private $username = ""; 
     39 
     40        private $password = ""; 
     41 
     42        private $host = ""; 
     43 
     44        private $port = 22; 
     45 
     46        private $mode = null; 
     47 
     48        private $_connection = null; 
     49 
     50        /** 
     51         * Sets the remote host 
     52         */ 
     53        function setHost($h) 
     54        { 
     55                $this->host = $h; 
     56        } 
     57 
     58        /** 
     59         * Returns the remote host 
     60         */ 
     61        function getHost() 
     62        { 
     63                return $this->host; 
     64        } 
     65 
     66        /** 
     67         * Sets the remote host port 
     68         */ 
     69        function setPort($p) 
     70        { 
     71                $this->port = $p; 
     72        } 
     73 
     74        /** 
     75         * Returns the remote host port 
     76         */ 
     77        function getPort() 
     78        { 
     79                return $this->port; 
     80        } 
     81 
     82        /** 
     83         * Sets the mode value 
     84         */ 
     85        function setMode($value) 
     86        { 
     87                $this->mode = $value; 
     88        } 
     89 
     90        /** 
     91         * Returns the mode value 
     92         */ 
     93        function getMode() 
     94        { 
     95                return $this->mode; 
     96        } 
     97 
     98        /** 
     99         * Sets the username of the user to scp 
     100         */ 
     101        function setUsername($username) 
     102        { 
     103                $this->username = $username; 
     104        } 
     105 
     106        /** 
     107         * Returns the username 
     108         */ 
     109        function getUsername() 
     110        { 
     111                return $this->username; 
     112        } 
     113 
     114        /** 
     115         * Sets the password of the user to scp 
     116         */ 
     117        function setPassword($password) 
     118        { 
     119                $this->password = $password; 
     120        } 
     121 
     122        /** 
     123         * Returns the password 
     124         */ 
     125        function getPassword() 
     126        { 
     127                return $this->password; 
     128        } 
     129 
     130        /** 
     131         * Sets the local path to scp from 
     132         */ 
     133        function setLocalFile($lFile) 
     134        { 
     135                $this->localFile = $lFile; 
     136        } 
     137 
     138        /** 
     139         * Returns the local path to scp from 
     140         */ 
     141        function getLocalFile($lFile) 
     142        { 
     143                return $this->localFile; 
     144        } 
     145 
     146        /** 
     147         * Sets the remote path to scp to 
     148         */ 
     149        function setRemoteFile($rFile) 
     150        { 
     151                $this->remoteFile = $rFile; 
     152        } 
     153 
     154        /** 
     155         * Returns the remote path to scp to 
     156         */ 
     157        function getRemoteFile($rFile) 
     158        { 
     159                return $this->remoteFile; 
     160        } 
     161 
     162        /** 
     163        * The init method: Do init steps. 
     164        */ 
     165        public function init() 
     166        { 
     167                if (function_exists('ssh2_connect')) { 
     168                        $this->_connection = ssh2_connect($this->host, $this->port); 
     169                        ssh2_auth_password($this->_connection, $this->username, $this->password); 
     170                } else { 
     171                        print ("ERROR: SSH Extension is not installed"); 
     172                } 
     173        } 
     174 
     175        /** 
     176         * The main entry point method. 
     177         */ 
     178        public function main() 
     179        { 
     180                if (function_exists('ssh2_scp_send') && !is_null($this->_connection)) 
     181                { 
     182                        if (!is_null($this->mode)) { 
     183                                ssh2_scp_send($this->_connection, $this->localFile, $this->remoteFile, $this->mode); 
     184                        } else { 
     185                                ssh2_scp_send($this->_connection, $this->localFile, $this->remoteFile); 
     186                        } 
     187                } else { 
     188                        print ("ERROR: No SSH Connection Available"); 
     189                } 
     190        } 
     191} 
     192?> 
  • tasks/ext/simpletest/SimpleTestCountResultFormatter.php

    diff -ru phing-orig/tasks/ext/simpletest/SimpleTestCountResultFormatter.php phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php
    old new  
    1 <?php 
    2 /** 
    3  * $Id: SimpleTestCountResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; 
    23  
    24 /** 
    25  * Dummy result formatter used to count SimpleTest results 
    26  * 
    27  * @author Michiel Rook <michiel.rook@gmail.com> 
    28  * @version $Id: SimpleTestCountResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
    29  * @package phing.tasks.ext.simpletest 
    30  * @since 2.2.0 
    31  */ 
    32 class SimpleTestCountResultFormatter extends SimpleTestResultFormatter 
    33 { 
    34         const SUCCESS = 0; 
    35         const FAILURES = 1; 
    36         const ERRORS = 2; 
    37          
    38         function getRetCode() 
    39         { 
    40                 if ($this->getExceptionCount() != 0) 
    41                 { 
    42                         return self::ERRORS; 
    43                 } 
    44                 else if ($this->getFailCount() != 0) 
    45                 { 
    46                         return self::FAILURES; 
    47                 } 
    48                  
    49                 return self::SUCCESS; 
    50         }        
    51 } 
     1<?php 
     2/** 
     3 * $Id: SimpleTestCountResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; 
     23 
     24/** 
     25 * Dummy result formatter used to count SimpleTest results 
     26 * 
     27 * @author Michiel Rook <michiel.rook@gmail.com> 
     28 * @version $Id: SimpleTestCountResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
     29 * @package phing.tasks.ext.simpletest 
     30 * @since 2.2.0 
     31 */ 
     32class SimpleTestCountResultFormatter extends SimpleTestResultFormatter 
     33{ 
     34        const SUCCESS = 0; 
     35        const FAILURES = 1; 
     36        const ERRORS = 2; 
     37         
     38        function getRetCode() 
     39        { 
     40                if ($this->getExceptionCount() != 0) 
     41                { 
     42                        return self::ERRORS; 
     43                } 
     44                else if ($this->getFailCount() != 0) 
     45                { 
     46                        return self::FAILURES; 
     47                } 
     48                 
     49                return self::SUCCESS; 
     50        }        
     51} 
    5252?> 
     53 No newline at end of file 
  • tasks/ext/simpletest/SimpleTestFormatterElement.php

    diff -ru phing-orig/tasks/ext/simpletest/SimpleTestFormatterElement.php phing/tasks/ext/simpletest/SimpleTestFormatterElement.php
    old new  
    1 <?php 
    2 /** 
    3  * $Id: SimpleTestFormatterElement.php 81 2006-07-06 13:07:29Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 require_once 'phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php'; 
    23 require_once 'phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php'; 
    24 require_once 'phing/tasks/ext/phpunit2/FormatterElement.php'; 
    25  
    26 /** 
    27  * Child class of "FormatterElement", overrides setType to provide other 
    28  * formatter classes for SimpleTest 
    29  * 
    30  * @author Michiel Rook <michiel.rook@gmail.com> 
    31  * @version $Id: SimpleTestFormatterElement.php 81 2006-07-06 13:07:29Z mrook $ 
    32  * @package phing.tasks.ext.simpletest 
    33  * @since 2.2.0 
    34  */ 
    35 class SimpleTestFormatterElement extends FormatterElement 
    36 { 
    37         function setType($type) 
    38         { 
    39                 $this->type = $type; 
    40  
    41                 if ($this->type == "xml") 
    42                 { 
    43                         $destFile = new PhingFile($this->toDir, 'testsuites.xml'); 
    44                         //$this->formatter = new SimpleTestXmlResultFormatter(); 
    45                 } 
    46                 else 
    47                 if ($this->type == "plain") 
    48                 { 
    49                         $this->formatter = new SimpleTestPlainResultFormatter(); 
    50                 } 
    51                 else 
    52                 if ($this->type == "summary") 
    53                 { 
    54                         $this->formatter = new SimpleTestSummaryResultFormatter(); 
    55                 } 
    56                 else 
    57                 { 
    58                         throw new BuildException("Formatter '" . $this->type . "' not implemented"); 
    59                 } 
    60         } 
    61 } 
     1<?php 
     2/** 
     3 * $Id: SimpleTestFormatterElement.php 81 2006-07-06 13:07:29Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22require_once 'phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php'; 
     23require_once 'phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php'; 
     24require_once 'phing/tasks/ext/phpunit2/FormatterElement.php'; 
     25 
     26/** 
     27 * Child class of "FormatterElement", overrides setType to provide other 
     28 * formatter classes for SimpleTest 
     29 * 
     30 * @author Michiel Rook <michiel.rook@gmail.com> 
     31 * @version $Id: SimpleTestFormatterElement.php 81 2006-07-06 13:07:29Z mrook $ 
     32 * @package phing.tasks.ext.simpletest 
     33 * @since 2.2.0 
     34 */ 
     35class SimpleTestFormatterElement extends FormatterElement 
     36{ 
     37        function setType($type) 
     38        { 
     39                $this->type = $type; 
     40 
     41                if ($this->type == "xml") 
     42                { 
     43                        $destFile = new PhingFile($this->toDir, 'testsuites.xml'); 
     44                        //$this->formatter = new SimpleTestXmlResultFormatter(); 
     45                } 
     46                else 
     47                if ($this->type == "plain") 
     48                { 
     49                        $this->formatter = new SimpleTestPlainResultFormatter(); 
     50                } 
     51                else 
     52                if ($this->type == "summary") 
     53                { 
     54                        $this->formatter = new SimpleTestSummaryResultFormatter(); 
     55                } 
     56                else 
     57                { 
     58                        throw new BuildException("Formatter '" . $this->type . "' not implemented"); 
     59                } 
     60        } 
     61} 
    6262?> 
     63 No newline at end of file 
  • tasks/ext/simpletest/SimpleTestPlainResultFormatter.php

    diff -ru phing-orig/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php
    old new  
    1 <?php 
    2 /** 
    3  * $Id: SimpleTestPlainResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; 
    23  
    24 /** 
    25  * Prints plain text output of the test to a specified Writer. 
    26  * 
    27  * @author Michiel Rook <michiel.rook@gmail.com> 
    28  * @version $Id: SimpleTestPlainResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
    29  * @package phing.tasks.ext.simpletest 
    30  * @since 2.2.0 
    31  */ 
    32 class SimpleTestPlainResultFormatter extends SimpleTestResultFormatter 
    33 { 
    34         private $inner = ""; 
    35          
    36         function getExtension() 
    37         { 
    38                 return ".txt"; 
    39         } 
    40          
    41         function getPreferredOutfile() 
    42         { 
    43                 return "testresults"; 
    44         } 
    45  
    46         function paintCaseStart($test_name) 
    47         { 
    48                 parent::paintCaseStart($test_name); 
    49                  
    50                 $this->inner = ""; 
    51         } 
    52          
    53         function paintCaseEnd($test_name) 
    54         { 
    55                 parent::paintCaseEnd($test_name); 
    56                  
    57                 /* Only count suites where more than one test was run */ 
    58                 if ($this->getRunCount()) 
    59                 { 
    60                         $sb.= "Testsuite: $test_name\n"; 
    61                         $sb.= "Tests run: " . $this->getRunCount(); 
    62                         $sb.= ", Failures: " . $this->getFailureCount(); 
    63                         $sb.= ", Errors: " . $this->getErrorCount(); 
    64                         $sb.= ", Time elapsed: " . $this->getElapsedTime(); 
    65                         $sb.= " sec\n"; 
    66  
    67                         if ($this->out != NULL) 
    68                         { 
    69                                 $this->out->write($sb); 
    70                                 $this->out->write($this->inner); 
    71                         } 
    72                 } 
    73         } 
    74  
    75         function paintError($message) 
    76         { 
    77                 parent::paintError($message); 
    78                  
    79                 $this->formatError("ERROR", $message); 
    80         } 
    81  
    82         function paintFail($message) 
    83         { 
    84                 parent::paintFail($message); 
    85                  
    86                 $this->formatError("FAILED", $message); 
    87         } 
    88  
    89         private function formatError($type, $message) 
    90         { 
    91                 $this->inner.= $this->getTestName() . " " . $type . "\n"; 
    92                 $this->inner.= $message . "\n";  
    93         } 
    94 } 
     1<?php 
     2/** 
     3 * $Id: SimpleTestPlainResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; 
     23 
     24/** 
     25 * Prints plain text output of the test to a specified Writer. 
     26 * 
     27 * @author Michiel Rook <michiel.rook@gmail.com> 
     28 * @version $Id: SimpleTestPlainResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
     29 * @package phing.tasks.ext.simpletest 
     30 * @since 2.2.0 
     31 */ 
     32class SimpleTestPlainResultFormatter extends SimpleTestResultFormatter 
     33{ 
     34        private $inner = ""; 
     35         
     36        function getExtension() 
     37        { 
     38                return ".txt"; 
     39        } 
     40         
     41        function getPreferredOutfile() 
     42        { 
     43                return "testresults"; 
     44        } 
     45 
     46        function paintCaseStart($test_name) 
     47        { 
     48                parent::paintCaseStart($test_name); 
     49                 
     50                $this->inner = ""; 
     51        } 
     52         
     53        function paintCaseEnd($test_name) 
     54        { 
     55                parent::paintCaseEnd($test_name); 
     56                 
     57                /* Only count suites where more than one test was run */ 
     58                if ($this->getRunCount()) 
     59                { 
     60                        $sb.= "Testsuite: $test_name\n"; 
     61                        $sb.= "Tests run: " . $this->getRunCount(); 
     62                        $sb.= ", Failures: " . $this->getFailureCount(); 
     63                        $sb.= ", Errors: " . $this->getErrorCount(); 
     64                        $sb.= ", Time elapsed: " . $this->getElapsedTime(); 
     65                        $sb.= " sec\n"; 
     66 
     67                        if ($this->out != NULL) 
     68                        { 
     69                                $this->out->write($sb); 
     70                                $this->out->write($this->inner); 
     71                        } 
     72                } 
     73        } 
     74 
     75        function paintError($message) 
     76        { 
     77                parent::paintError($message); 
     78                 
     79                $this->formatError("ERROR", $message); 
     80        } 
     81 
     82        function paintFail($message) 
     83        { 
     84                parent::paintFail($message); 
     85                 
     86                $this->formatError("FAILED", $message); 
     87        } 
     88 
     89        private function formatError($type, $message) 
     90        { 
     91                $this->inner.= $this->getTestName() . " " . $type . "\n"; 
     92                $this->inner.= $message . "\n";  
     93        } 
     94} 
    9595?> 
     96 No newline at end of file 
  • tasks/ext/simpletest/SimpleTestResultFormatter.php

    diff -ru phing-orig/tasks/ext/simpletest/SimpleTestResultFormatter.php phing/tasks/ext/simpletest/SimpleTestResultFormatter.php
    old new  
    1 <?php 
    2 /** 
    3  * $Id: SimpleTestResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 require_once 'simpletest/scorer.php'; 
    23  
    24 require_once 'phing/system/io/Writer.php'; 
    25  
    26 /** 
    27  * This abstract class describes classes that format the results of a SimpleTest testrun. 
    28  * 
    29  * @author Michiel Rook <michiel.rook@gmail.com> 
    30  * @version $Id: SimpleTestResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
    31  * @package phing.tasks.ext.phpunit2 
    32  * @since 2.2.0 
    33  */ 
    34 abstract class SimpleTestResultFormatter extends SimpleReporter 
    35 { 
    36         protected $out = NULL; 
    37          
    38         protected $project = NULL; 
    39          
    40         private $timer = NULL; 
    41  
    42         private $runCount = 0; 
    43          
    44         private $failureCount = 0; 
    45          
    46         private $errorCount = 0;         
    47  
    48         private $currentTest = ""; 
    49          
    50         /** 
    51          * Sets the writer the formatter is supposed to write its results to. 
    52          */ 
    53         function setOutput(Writer $out) 
    54         { 
    55                 $this->out = $out;       
    56         } 
    57  
    58         /** 
    59          * Returns the extension used for this formatter 
    60          * 
    61          * @return string the extension 
    62          */ 
    63         function getExtension() 
    64         { 
    65                 return ""; 
    66         } 
    67  
    68         /** 
    69          * Sets the project 
    70          * 
    71          * @param Project the project 
    72          */ 
    73         function setProject(Project $project) 
    74         { 
    75                 $this->project = $project; 
    76         } 
    77          
    78         function getPreferredOutfile() 
    79         { 
    80                 return ""; 
    81         } 
    82          
    83         function paintMethodStart($test_name) 
    84         { 
    85                 parent::paintMethodStart($test_name); 
    86                  
    87                 $this->currentTest = $test_name; 
    88         } 
    89          
    90         function paintMethodEnd($test_name) 
    91         { 
    92                 parent::paintMethodEnd($test_name); 
    93                  
    94                 $this->runCount++; 
    95         } 
    96          
    97         function paintCaseStart($test_name) 
    98         { 
    99                 parent::paintCaseStart($test_name); 
    100                  
    101                 $this->runCount = 0; 
    102                 $this->failureCount = 0; 
    103                 $this->errorCount = 0; 
    104                  
    105                 $this->timer = new Timer(); 
    106                 $this->timer->start(); 
    107         } 
    108                  
    109         function paintCaseEnd($test_name) 
    110         { 
    111                 parent::paintCaseEnd($test_name); 
    112                  
    113                 $this->timer->stop(); 
    114         } 
    115  
    116         function paintError($message) 
    117         { 
    118                 parent::paintError($message); 
    119                  
    120                 $this->errorCount++; 
    121         } 
    122  
    123         function paintFail($message) 
    124         { 
    125                 parent::paintFail($message); 
    126                  
    127                 $this->failureCount++; 
    128         } 
    129  
    130         function getRunCount() 
    131         { 
    132                 return $this->runCount; 
    133         } 
    134          
    135         function getFailureCount() 
    136         { 
    137                 return $this->failureCount; 
    138         } 
    139          
    140         function getErrorCount() 
    141         { 
    142                 return $this->errorCount; 
    143         } 
    144          
    145         function getTestName() 
    146         { 
    147                 return $this->currentTest; 
    148         } 
    149          
    150         function getElapsedTime() 
    151         { 
    152                 if ($this->timer) 
    153                 { 
    154                         return $this->timer->getElapsedTime(); 
    155                 } 
    156                 else 
    157                 { 
    158                         return 0; 
    159                 } 
    160         } 
    161 } 
     1<?php 
     2/** 
     3 * $Id: SimpleTestResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22require_once 'simpletest/scorer.php'; 
     23 
     24require_once 'phing/system/io/Writer.php'; 
     25 
     26/** 
     27 * This abstract class describes classes that format the results of a SimpleTest testrun. 
     28 * 
     29 * @author Michiel Rook <michiel.rook@gmail.com> 
     30 * @version $Id: SimpleTestResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
     31 * @package phing.tasks.ext.phpunit2 
     32 * @since 2.2.0 
     33 */ 
     34abstract class SimpleTestResultFormatter extends SimpleReporter 
     35{ 
     36        protected $out = NULL; 
     37         
     38        protected $project = NULL; 
     39         
     40        private $timer = NULL; 
     41 
     42        private $runCount = 0; 
     43         
     44        private $failureCount = 0; 
     45         
     46        private $errorCount = 0;         
     47 
     48        private $currentTest = ""; 
     49         
     50        /** 
     51         * Sets the writer the formatter is supposed to write its results to. 
     52         */ 
     53        function setOutput(Writer $out) 
     54        { 
     55                $this->out = $out;       
     56        } 
     57 
     58        /** 
     59         * Returns the extension used for this formatter 
     60         * 
     61         * @return string the extension 
     62         */ 
     63        function getExtension() 
     64        { 
     65                return ""; 
     66        } 
     67 
     68        /** 
     69         * Sets the project 
     70         * 
     71         * @param Project the project 
     72         */ 
     73        function setProject(Project $project) 
     74        { 
     75                $this->project = $project; 
     76        } 
     77         
     78        function getPreferredOutfile() 
     79        { 
     80                return ""; 
     81        } 
     82         
     83        function paintMethodStart($test_name) 
     84        { 
     85                parent::paintMethodStart($test_name); 
     86                 
     87                $this->currentTest = $test_name; 
     88        } 
     89         
     90        function paintMethodEnd($test_name) 
     91        { 
     92                parent::paintMethodEnd($test_name); 
     93                 
     94                $this->runCount++; 
     95        } 
     96         
     97        function paintCaseStart($test_name) 
     98        { 
     99                parent::paintCaseStart($test_name); 
     100                 
     101                $this->runCount = 0; 
     102                $this->failureCount = 0; 
     103                $this->errorCount = 0; 
     104                 
     105                $this->timer = new Timer(); 
     106                $this->timer->start(); 
     107        } 
     108                 
     109        function paintCaseEnd($test_name) 
     110        { 
     111                parent::paintCaseEnd($test_name); 
     112                 
     113                $this->timer->stop(); 
     114        } 
     115 
     116        function paintError($message) 
     117        { 
     118                parent::paintError($message); 
     119                 
     120                $this->errorCount++; 
     121        } 
     122 
     123        function paintFail($message) 
     124        { 
     125                parent::paintFail($message); 
     126                 
     127                $this->failureCount++; 
     128        } 
     129 
     130        function getRunCount() 
     131        { 
     132                return $this->runCount; 
     133        } 
     134         
     135        function getFailureCount() 
     136        { 
     137                return $this->failureCount; 
     138        } 
     139         
     140        function getErrorCount() 
     141        { 
     142                return $this->errorCount; 
     143        } 
     144         
     145        function getTestName() 
     146        { 
     147                return $this->currentTest; 
     148        } 
     149         
     150        function getElapsedTime() 
     151        { 
     152                if ($this->timer) 
     153                { 
     154                        return $this->timer->getElapsedTime(); 
     155                } 
     156                else 
     157                { 
     158                        return 0; 
     159                } 
     160        } 
     161} 
    162162?> 
     163 No newline at end of file 
  • tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php

    diff -ru phing-orig/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php
    old new  
    1 <?php 
    2 /** 
    3  * $Id: SimpleTestSummaryResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; 
    23  
    24 /** 
    25  * Prints short summary output of the test to Phing's logging system. 
    26  * 
    27  * @author Michiel Rook <michiel.rook@gmail.com> 
    28  * @version $Id: SimpleTestSummaryResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
    29  * @package phing.tasks.ext.simpletest 
    30  * @since 2.2.0 
    31  */ 
    32 class SimpleTestSummaryResultFormatter extends SimpleTestResultFormatter 
    33 { 
    34         function paintCaseEnd($test_name) 
    35         { 
    36                 parent::paintCaseEnd($test_name); 
    37                  
    38                 /* Only count suites where more than one test was run */ 
    39                 if ($this->getRunCount()) 
    40                 { 
    41                         $sb.= "Tests run: " . $this->getRunCount(); 
    42                         $sb.= ", Failures: " . $this->getFailureCount(); 
    43                         $sb.= ", Errors: " . $this->getErrorCount(); 
    44                         $sb.= ", Time elapsed: " . $this->getElapsedTime(); 
    45                         $sb.= " sec\n"; 
    46  
    47                         if ($this->out != NULL) 
    48                         { 
    49                                 $this->out->write($sb); 
    50                         } 
    51                 } 
    52         } 
    53 } 
     1<?php 
     2/** 
     3 * $Id: SimpleTestSummaryResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22require_once 'phing/tasks/ext/simpletest/SimpleTestResultFormatter.php'; 
     23 
     24/** 
     25 * Prints short summary output of the test to Phing's logging system. 
     26 * 
     27 * @author Michiel Rook <michiel.rook@gmail.com> 
     28 * @version $Id: SimpleTestSummaryResultFormatter.php 81 2006-07-06 13:07:29Z mrook $ 
     29 * @package phing.tasks.ext.simpletest 
     30 * @since 2.2.0 
     31 */ 
     32class SimpleTestSummaryResultFormatter extends SimpleTestResultFormatter 
     33{ 
     34        function paintCaseEnd($test_name) 
     35        { 
     36                parent::paintCaseEnd($test_name); 
     37                 
     38                /* Only count suites where more than one test was run */ 
     39                if ($this->getRunCount()) 
     40                { 
     41                        $sb.= "Tests run: " . $this->getRunCount(); 
     42                        $sb.= ", Failures: " . $this->getFailureCount(); 
     43                        $sb.= ", Errors: " . $this->getErrorCount(); 
     44                        $sb.= ", Time elapsed: " . $this->getElapsedTime(); 
     45                        $sb.= " sec\n"; 
     46 
     47                        if ($this->out != NULL) 
     48                        { 
     49                                $this->out->write($sb); 
     50                        } 
     51                } 
     52        } 
     53} 
    5454?> 
     55 No newline at end of file 
  • tasks/ext/svn/SvnBaseTask.php

    diff -ru phing-orig/tasks/ext/svn/SvnBaseTask.php phing/tasks/ext/svn/SvnBaseTask.php
    old new  
    1 <?php 
    2 /* 
    3  *  $Id: SvnBaseTask.php 119 2006-09-14 20:02:22Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21   
    22 include_once 'phing/Task.php'; 
    23  
    24 /** 
    25  * Base class for Subversion tasks 
    26  * 
    27  * @author Michiel Rook <michiel.rook@gmail.com> 
    28  * @author Andrew Eddie <andrew.eddie@jamboworks.com>  
    29  * @version $Id: SvnBaseTask.php 119 2006-09-14 20:02:22Z mrook $ 
    30  * @package phing.tasks.ext.svn 
    31  * @see VersionControl_SVN 
    32  * @since 2.2.0 
    33  */ 
    34 abstract class SvnBaseTask extends Task 
    35 { 
    36         private $workingCopy = ""; 
    37          
    38         private $repositoryUrl = ""; 
    39          
    40         private $svnPath = "/usr/bin/svn"; 
    41          
    42         private $svn = NULL; 
    43          
    44         private $mode = ""; 
    45          
    46         private $svnArgs = array(); 
    47          
    48         private $svnSwitches = array(); 
    49  
    50         private $toDir = ""; 
    51  
    52         /** 
    53          * Initialize Task. 
    54          * This method includes any necessary SVN libraries and triggers 
    55          * appropriate error if they cannot be found.  This is not done in header 
    56          * because we may want this class to be loaded w/o triggering an error. 
    57          */ 
    58         function init() { 
    59                 include_once 'VersionControl/SVN.php'; 
    60                 if (!class_exists('VersionControl_SVN')) { 
    61                         throw new Exception("SvnLastRevisionTask depends on PEAR VersionControl_SVN package being installed."); 
    62                 } 
    63         } 
    64  
    65         /** 
    66          * Sets the path to the workingcopy 
    67          */ 
    68         function setWorkingCopy($workingCopy) 
    69         { 
    70                 $this->workingCopy = $workingCopy; 
    71         } 
    72  
    73         /** 
    74          * Returns the path to the workingcopy 
    75          */ 
    76         function getWorkingCopy() 
    77         { 
    78                 return $this->workingCopy; 
    79         } 
    80  
    81         /** 
    82          * Sets the path/URI to the repository 
    83          */ 
    84         function setRepositoryUrl($repositoryUrl) 
    85         { 
    86                 $this->repositoryUrl = $repositoryUrl; 
    87         } 
    88  
    89         /** 
    90          * Returns the path/URI to the repository 
    91          */ 
    92         function getRepositoryUrl() 
    93         { 
    94                 return $this->repositoryUrl; 
    95         } 
    96  
    97         /** 
    98          * Sets the path to the SVN executable 
    99          */ 
    100         function setSvnPath($svnPath) 
    101         { 
    102                 $this->svnPath = $svnPath; 
    103         } 
    104  
    105         /** 
    106          * Returns the path to the SVN executable 
    107          */ 
    108         function getSvnPath() 
    109         { 
    110                 return $this->svnPath; 
    111         } 
    112  
    113         // 
    114         // Args 
    115         // 
    116  
    117         /** 
    118          * Sets the path to export/checkout to 
    119          */ 
    120         function setToDir($toDir) 
    121         { 
    122                 $this->toDir = $toDir; 
    123         } 
    124  
    125         /** 
    126          * Returns the path to export/checkout to 
    127          */ 
    128         function getToDir() 
    129         { 
    130                 return $this->toDir; 
    131         } 
    132  
    133         // 
    134         // Switches 
    135         // 
    136  
    137         /** 
    138          * Sets the force switch 
    139          */ 
    140         function setForce($value) 
    141         { 
    142                 $this->svnSwitches['force'] = $value; 
    143         } 
    144  
    145         /** 
    146          * Returns the forec switch 
    147          */ 
    148         function getForce() 
    149         { 
    150                 return isset( $this->svnSwitches['force'] ) ? $this->svnSwitches['force'] : ''; 
    151         } 
    152  
    153         /** 
    154          * Sets the username of the user to export 
    155          */ 
    156         function setUsername($value) 
    157         { 
    158                 $this->svnSwitches['username'] = $value; 
    159         } 
    160  
    161         /** 
    162          * Returns the username 
    163          */ 
    164         function getUsername() 
    165         { 
    166                 return isset( $this->svnSwitches['username'] ) ? $this->svnSwitches['username'] : ''; 
    167         } 
    168  
    169         /** 
    170          * Sets the password of the user to export 
    171          */ 
    172         function setPassword($value) 
    173         { 
    174                 $this->svnSwitches['password'] = $value; 
    175         } 
    176  
    177         /** 
    178          * Returns the password 
    179          */ 
    180         function getPassword() 
    181         { 
    182                 return isset( $this->svnSwitches['password'] ) ? $this->svnSwitches['password'] : ''; 
    183         } 
    184  
    185         /** 
    186          * Sets the password of the user to export 
    187          */ 
    188         function setNoCache($value) 
    189         { 
    190                 $this->svnSwitches['no-auth-cache'] = $value; 
    191         } 
    192  
    193         /** 
    194          * Returns the password 
    195          */ 
    196         function getNoCache() 
    197         { 
    198                 return isset( $this->svnSwitches['no-auth-cache'] ) ? $this->svnSwitches['no-auth-cache'] : ''; 
    199         } 
    200  
    201         /** 
    202          * Creates a VersionControl_SVN class based on $mode 
    203          * 
    204          * @param string The SVN mode to use (info, export, checkout, ...) 
    205          * @throws BuildException 
    206          */ 
    207         protected function setup($mode) 
    208         { 
    209                 $this->mode = $mode; 
    210                  
    211                 // Set up runtime options. Will be passed to all 
    212                 // subclasses. 
    213                 $options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_ASSOC, 'svn_path' => $this->getSvnPath()); 
    214                  
    215                 // Pass array of subcommands we need to factory 
    216                 $this->svn = VersionControl_SVN::factory($mode, $options); 
    217  
    218                 if (!empty($this->repositoryUrl)) 
    219                 { 
    220                         $this->svnArgs = array($this->repositoryUrl); 
    221                 } 
    222                 else 
    223                 if (!empty($this->workingCopy)) 
    224                 { 
    225                         if (is_dir($this->workingCopy)) 
    226                         { 
    227                                 if (in_array(".svn", scandir($this->workingCopy))) 
    228                                 { 
    229                                         $this->svnArgs = array($this->workingCopy); 
    230                                 } 
    231                                 else 
    232                                 { 
    233                                         throw new BuildException("'".$this->workingCopy."' doesn't seem to be a working copy"); 
    234                                 } 
    235                         } 
    236                         else 
    237                         { 
    238                                 throw new BuildException("'".$this->workingCopy."' is not a directory"); 
    239                         } 
    240                 } 
    241         } 
    242          
    243         /** 
    244          * Executes the constructed VersionControl_SVN instance 
    245          * 
    246          * @param array Additional arguments to pass to SVN. 
    247          * @param array Switches to pass to SVN. 
    248          * @return string Output generated by SVN. 
    249          */ 
    250         protected function run($args = array(), $switches = array()) 
    251         { 
    252                 $svnstack = PEAR_ErrorStack::singleton('VersionControl_SVN'); 
    253                  
    254                 $tempArgs = $this->svnArgs; 
    255                  
    256                 $tempArgs = array_merge($tempArgs, $args); 
    257  
    258                 $tempSwitches = $this->svnSwitches; 
    259                  
    260                 $tempSwitches = array_merge($tempSwitches, $switches); 
    261  
    262                 if ($output = $this->svn->run($tempArgs, $tempSwitches)) 
    263                 { 
    264                         return $output; 
    265                 } 
    266                 else 
    267                 { 
    268                         if (count($errs = $svnstack->getErrors())) 
    269                         { 
    270                                 $err = current($errs); 
    271  
    272                                 throw new BuildException("Failed to run the 'svn " . $this->mode . "' command: " . $err['message']); 
    273                         } 
    274                 } 
    275         } 
    276 } 
     1<?php 
     2/* 
     3 *  $Id: SvnBaseTask.php 119 2006-09-14 20:02:22Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21  
     22include_once 'phing/Task.php'; 
     23 
     24/** 
     25 * Base class for Subversion tasks 
     26 * 
     27 * @author Michiel Rook <michiel.rook@gmail.com> 
     28 * @author Andrew Eddie <andrew.eddie@jamboworks.com>  
     29 * @version $Id: SvnBaseTask.php 119 2006-09-14 20:02:22Z mrook $ 
     30 * @package phing.tasks.ext.svn 
     31 * @see VersionControl_SVN 
     32 * @since 2.2.0 
     33 */ 
     34abstract class SvnBaseTask extends Task 
     35{ 
     36        private $workingCopy = ""; 
     37         
     38        private $repositoryUrl = ""; 
     39         
     40        private $svnPath = "/usr/bin/svn"; 
     41         
     42        private $svn = NULL; 
     43         
     44        private $mode = ""; 
     45         
     46        private $svnArgs = array(); 
     47         
     48        private $svnSwitches = array(); 
     49 
     50        private $toDir = ""; 
     51 
     52        /** 
     53         * Initialize Task. 
     54         * This method includes any necessary SVN libraries and triggers 
     55         * appropriate error if they cannot be found.  This is not done in header 
     56         * because we may want this class to be loaded w/o triggering an error. 
     57         */ 
     58        function init() { 
     59                include_once 'VersionControl/SVN.php'; 
     60                if (!class_exists('VersionControl_SVN')) { 
     61                        throw new Exception("SvnLastRevisionTask depends on PEAR VersionControl_SVN package being installed."); 
     62                } 
     63        } 
     64 
     65        /** 
     66         * Sets the path to the workingcopy 
     67         */ 
     68        function setWorkingCopy($workingCopy) 
     69        { 
     70                $this->workingCopy = $workingCopy; 
     71        } 
     72 
     73        /** 
     74         * Returns the path to the workingcopy 
     75         */ 
     76        function getWorkingCopy() 
     77        { 
     78                return $this->workingCopy; 
     79        } 
     80 
     81        /** 
     82         * Sets the path/URI to the repository 
     83         */ 
     84        function setRepositoryUrl($repositoryUrl) 
     85        { 
     86                $this->repositoryUrl = $repositoryUrl; 
     87        } 
     88 
     89        /** 
     90         * Returns the path/URI to the repository 
     91         */ 
     92        function getRepositoryUrl() 
     93        { 
     94                return $this->repositoryUrl; 
     95        } 
     96 
     97        /** 
     98         * Sets the path to the SVN executable 
     99         */ 
     100        function setSvnPath($svnPath) 
     101        { 
     102                $this->svnPath = $svnPath; 
     103        } 
     104 
     105        /** 
     106         * Returns the path to the SVN executable 
     107         */ 
     108        function getSvnPath() 
     109        { 
     110                return $this->svnPath; 
     111        } 
     112 
     113        // 
     114        // Args 
     115        // 
     116 
     117        /** 
     118         * Sets the path to export/checkout to 
     119         */ 
     120        function setToDir($toDir) 
     121        { 
     122                $this->toDir = $toDir; 
     123        } 
     124 
     125        /** 
     126         * Returns the path to export/checkout to 
     127         */ 
     128        function getToDir() 
     129        { 
     130                return $this->toDir; 
     131        } 
     132 
     133        // 
     134        // Switches 
     135        // 
     136 
     137        /** 
     138         * Sets the force switch 
     139         */ 
     140        function setForce($value) 
     141        { 
     142                $this->svnSwitches['force'] = $value; 
     143        } 
     144 
     145        /** 
     146         * Returns the forec switch 
     147         */ 
     148        function getForce() 
     149        { 
     150                return isset( $this->svnSwitches['force'] ) ? $this->svnSwitches['force'] : ''; 
     151        } 
     152 
     153        /** 
     154         * Sets the username of the user to export 
     155         */ 
     156        function setUsername($value) 
     157        { 
     158                $this->svnSwitches['username'] = $value; 
     159        } 
     160 
     161        /** 
     162         * Returns the username 
     163         */ 
     164        function getUsername() 
     165        { 
     166                return isset( $this->svnSwitches['username'] ) ? $this->svnSwitches['username'] : ''; 
     167        } 
     168 
     169        /** 
     170         * Sets the password of the user to export 
     171         */ 
     172        function setPassword($value) 
     173        { 
     174                $this->svnSwitches['password'] = $value; 
     175        } 
     176 
     177        /** 
     178         * Returns the password 
     179         */ 
     180        function getPassword() 
     181        { 
     182                return isset( $this->svnSwitches['password'] ) ? $this->svnSwitches['password'] : ''; 
     183        } 
     184 
     185        /** 
     186         * Sets the password of the user to export 
     187         */ 
     188        function setNoCache($value) 
     189        { 
     190                $this->svnSwitches['no-auth-cache'] = $value; 
     191        } 
     192 
     193        /** 
     194         * Returns the password 
     195         */ 
     196        function getNoCache() 
     197        { 
     198                return isset( $this->svnSwitches['no-auth-cache'] ) ? $this->svnSwitches['no-auth-cache'] : ''; 
     199        } 
     200 
     201        /** 
     202         * Creates a VersionControl_SVN class based on $mode 
     203         * 
     204         * @param string The SVN mode to use (info, export, checkout, ...) 
     205         * @throws BuildException 
     206         */ 
     207        protected function setup($mode) 
     208        { 
     209                $this->mode = $mode; 
     210                 
     211                // Set up runtime options. Will be passed to all 
     212                // subclasses. 
     213                $options = array('fetchmode' => VERSIONCONTROL_SVN_FETCHMODE_ASSOC, 'svn_path' => $this->getSvnPath()); 
     214                 
     215                // Pass array of subcommands we need to factory 
     216                $this->svn = VersionControl_SVN::factory($mode, $options); 
     217 
     218                if (!empty($this->repositoryUrl)) 
     219                { 
     220                        $this->svnArgs = array($this->repositoryUrl); 
     221                } 
     222                else 
     223                if (!empty($this->workingCopy)) 
     224                { 
     225                        if (is_dir($this->workingCopy)) 
     226                        { 
     227                                if (in_array(".svn", scandir($this->workingCopy))) 
     228                                { 
     229                                        $this->svnArgs = array($this->workingCopy); 
     230                                } 
     231                                else 
     232                                { 
     233                                        throw new BuildException("'".$this->workingCopy."' doesn't seem to be a working copy"); 
     234                                } 
     235                        } 
     236                        else 
     237                        { 
     238                                throw new BuildException("'".$this->workingCopy."' is not a directory"); 
     239                        } 
     240                } 
     241        } 
     242         
     243        /** 
     244         * Executes the constructed VersionControl_SVN instance 
     245         * 
     246         * @param array Additional arguments to pass to SVN. 
     247         * @param array Switches to pass to SVN. 
     248         * @return string Output generated by SVN. 
     249         */ 
     250        protected function run($args = array(), $switches = array()) 
     251        { 
     252                $svnstack = PEAR_ErrorStack::singleton('VersionControl_SVN'); 
     253                 
     254                $tempArgs = $this->svnArgs; 
     255                 
     256                $tempArgs = array_merge($tempArgs, $args); 
     257 
     258                $tempSwitches = $this->svnSwitches; 
     259                 
     260                $tempSwitches = array_merge($tempSwitches, $switches); 
     261 
     262                if ($output = $this->svn->run($tempArgs, $tempSwitches)) 
     263                { 
     264                        return $output; 
     265                } 
     266                else 
     267                { 
     268                        if (count($errs = $svnstack->getErrors())) 
     269                        { 
     270                                $err = current($errs); 
     271 
     272                                throw new BuildException("Failed to run the 'svn " . $this->mode . "' command: " . $err['message']); 
     273                        } 
     274                } 
     275        } 
     276} 
    277277?> 
     278 No newline at end of file 
  • tasks/ext/svn/SvnCheckoutTask.php

    diff -ru phing-orig/tasks/ext/svn/SvnCheckoutTask.php phing/tasks/ext/svn/SvnCheckoutTask.php
    old new  
    1 <?php 
    2 /** 
    3  * $Id: SvnCheckoutTask.php 123 2006-09-14 20:19:08Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 require_once 'phing/Task.php'; 
    23 require_once 'phing/tasks/ext/svn/SvnBaseTask.php'; 
    24  
    25 /** 
    26  * Checks out a repository to a local directory 
    27  * 
    28  * @author Andrew Eddie <andrew.eddie@jamboworks.com> 
    29  * @version $Id: SvnCheckoutTask.php 123 2006-09-14 20:19:08Z mrook $ 
    30  * @package phing.tasks.ext.svn 
    31  * @since 2.3.0 
    32  */ 
    33 class SvnCheckoutTask extends SvnBaseTask 
    34 { 
    35         /** 
    36          * The main entry point 
    37          * 
    38          * @throws BuildException 
    39          */ 
    40         function main() 
    41         { 
    42                 $this->setup('checkout'); 
    43  
    44                 $this->log("Checking out SVN repository to '" . $this->getToDir() . "'"); 
    45  
    46                 $this->run(array($this->getToDir())); 
    47         } 
    48 } 
    49 ?> 
     1<?php 
     2/** 
     3 * $Id: SvnCheckoutTask.php 123 2006-09-14 20:19:08Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22require_once 'phing/Task.php'; 
     23require_once 'phing/tasks/ext/svn/SvnBaseTask.php'; 
     24 
     25/** 
     26 * Checks out a repository to a local directory 
     27 * 
     28 * @author Andrew Eddie <andrew.eddie@jamboworks.com> 
     29 * @version $Id: SvnCheckoutTask.php 123 2006-09-14 20:19:08Z mrook $ 
     30 * @package phing.tasks.ext.svn 
     31 * @since 2.3.0 
     32 */ 
     33class SvnCheckoutTask extends SvnBaseTask 
     34{ 
     35        /** 
     36         * The main entry point 
     37         * 
     38         * @throws BuildException 
     39         */ 
     40        function main() 
     41        { 
     42                $this->setup('checkout'); 
     43 
     44                $this->log("Checking out SVN repository to '" . $this->getToDir() . "'"); 
     45 
     46                $this->run(array($this->getToDir())); 
     47        } 
     48} 
     49?> 
  • tasks/ext/svn/SvnExportTask.php

    diff -ru phing-orig/tasks/ext/svn/SvnExportTask.php phing/tasks/ext/svn/SvnExportTask.php
    old new  
    1 <?php 
    2 /** 
    3  * $Id: SvnExportTask.php 119 2006-09-14 20:02:22Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 require_once 'phing/Task.php'; 
    23 require_once 'phing/tasks/ext/svn/SvnBaseTask.php'; 
    24  
    25 /** 
    26  * Exports/checks out a repository to a local directory 
    27  * with authentication  
    28  * 
    29  * @author Michiel Rook <michiel.rook@gmail.com> 
    30  * @author Andrew Eddie <andrew.eddie@jamboworks.com>  
    31  * @version $Id: SvnExportTask.php 119 2006-09-14 20:02:22Z mrook $ 
    32  * @package phing.tasks.ext.svn 
    33  * @since 2.2.0 
    34  */ 
    35 class SvnExportTask extends SvnBaseTask 
    36 { 
    37         /** 
    38          * The main entry point 
    39          * 
    40          * @throws BuildException 
    41          */ 
    42         function main() 
    43         { 
    44                 $this->setup('export'); 
    45                  
    46                 $this->log("Exporting SVN repository to '" . $this->getToDir() . "'"); 
    47  
    48                 $this->run(array($this->getToDir())); 
    49         } 
    50 } 
     1<?php 
     2/** 
     3 * $Id: SvnExportTask.php 119 2006-09-14 20:02:22Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22require_once 'phing/Task.php'; 
     23require_once 'phing/tasks/ext/svn/SvnBaseTask.php'; 
     24 
     25/** 
     26 * Exports/checks out a repository to a local directory 
     27 * with authentication  
     28 * 
     29 * @author Michiel Rook <michiel.rook@gmail.com> 
     30 * @author Andrew Eddie <andrew.eddie@jamboworks.com>  
     31 * @version $Id: SvnExportTask.php 119 2006-09-14 20:02:22Z mrook $ 
     32 * @package phing.tasks.ext.svn 
     33 * @since 2.2.0 
     34 */ 
     35class SvnExportTask extends SvnBaseTask 
     36{ 
     37        /** 
     38         * The main entry point 
     39         * 
     40         * @throws BuildException 
     41         */ 
     42        function main() 
     43        { 
     44                $this->setup('export'); 
     45                 
     46                $this->log("Exporting SVN repository to '" . $this->getToDir() . "'"); 
     47 
     48                $this->run(array($this->getToDir())); 
     49        } 
     50} 
    5151?> 
     52 No newline at end of file 
  • tasks/ext/svn/SvnUpdateTask.php

    diff -ru phing-orig/tasks/ext/svn/SvnUpdateTask.php phing/tasks/ext/svn/SvnUpdateTask.php
    old new  
    1 <?php 
    2 /** 
    3  * $Id: SvnUpdateTask.php 123 2006-09-14 20:19:08Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 require_once 'phing/Task.php'; 
    23 require_once 'phing/tasks/ext/svn/SvnBaseTask.php'; 
    24  
    25 /** 
    26  * Updates a repository in local directory 
    27  * 
    28  * @author Andrew Eddie <andrew.eddie@jamboworks.com> 
    29  * @version $Id: SvnUpdateTask.php 123 2006-09-14 20:19:08Z mrook $ 
    30  * @package phing.tasks.ext.svn 
    31  * @since 2.3.0 
    32  */ 
    33 class SvnUpdateTask extends SvnBaseTask 
    34 { 
    35         /** 
    36          * The main entry point 
    37          * 
    38          * @throws BuildException 
    39          */ 
    40         function main() 
    41         { 
    42                 $this->setup('update'); 
    43  
    44                 $this->log("Updating SVN repository at '" . $this->getToDir() . "'"); 
    45  
    46                 $this->run(array($this->getToDir())); 
    47         } 
    48 } 
    49 ?> 
     1<?php 
     2/** 
     3 * $Id: SvnUpdateTask.php 123 2006-09-14 20:19:08Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22require_once 'phing/Task.php'; 
     23require_once 'phing/tasks/ext/svn/SvnBaseTask.php'; 
     24 
     25/** 
     26 * Updates a repository in local directory 
     27 * 
     28 * @author Andrew Eddie <andrew.eddie@jamboworks.com> 
     29 * @version $Id: SvnUpdateTask.php 123 2006-09-14 20:19:08Z mrook $ 
     30 * @package phing.tasks.ext.svn 
     31 * @since 2.3.0 
     32 */ 
     33class SvnUpdateTask extends SvnBaseTask 
     34{ 
     35        /** 
     36         * The main entry point 
     37         * 
     38         * @throws BuildException 
     39         */ 
     40        function main() 
     41        { 
     42                $this->setup('update'); 
     43 
     44                $this->log("Updating SVN repository at '" . $this->getToDir() . "'"); 
     45 
     46                $this->run(array($this->getToDir())); 
     47        } 
     48} 
     49?> 
  • tasks/system/condition/ReferenceExistsCondition.php

    diff -ru phing-orig/tasks/system/condition/ReferenceExistsCondition.php phing/tasks/system/condition/ReferenceExistsCondition.php
    old new  
    1 <?php 
    2 /* 
    3  *  $Id: ReferenceExistsCondition.php 43 2006-03-10 14:31:51Z mrook $ 
    4  * 
    5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
    8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
    12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
    16  * 
    17  * This software consists of voluntary contributions made by many individuals 
    18  * and is licensed under the LGPL. For more information please see 
    19  * <http://phing.info>. 
    20  */ 
    21  
    22 require_once 'phing/ProjectComponent.php'; require_once 'phing/tasks/system/condition/Condition.php'; 
    23  
    24 /** 
    25  * Condition that tests whether a given reference exists. 
    26  * 
    27  * @author Matthias Pigulla <mp@webfactory.de> (Phing) 
    28  * @version $Revision: 1.1 $ 
    29  * @package phing.tasks.system.condition  */ 
    30 class ReferenceExistsCondition extends ProjectComponent implements Condition { 
    31      
    32     private $refid; 
    33  
    34     public function setRef($id) { 
    35       $this->refid = (string) $id; 
    36     } 
    37  
    38     /** 
    39      * Check whether the reference exists. 
    40      * @throws BuildException 
    41      */ 
    42     public function evaluate()  { 
    43         if ($this->refid === null) { 
    44             throw new BuildException("No ref attribute specified for reference-exists " 
    45                                      . "condition"); 
    46         }         
    47         $refs = $this->project->getReferences(); 
    48         return isset($refs[$this->refid]); 
    49     } 
    50  
    51 } 
    52  
     1<?php 
     2/* 
     3 *  $Id: ReferenceExistsCondition.php 43 2006-03-10 14:31:51Z mrook $ 
     4 * 
     5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
     6 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
     7 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
     8 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
     9 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
     10 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
     11 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
     12 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
     13 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
     14 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
     15 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     16 * 
     17 * This software consists of voluntary contributions made by many individuals 
     18 * and is licensed under the LGPL. For more information please see 
     19 * <http://phing.info>. 
     20 */ 
     21 
     22require_once 'phing/ProjectComponent.php'; require_once 'phing/tasks/system/condition/Condition.php'; 
     23 
     24/** 
     25 * Condition that tests whether a given reference exists. 
     26 * 
     27 * @author Matthias Pigulla <mp@webfactory.de> (Phing) 
     28 * @version $Revision: 1.1 $ 
     29 * @package phing.tasks.system.condition  */ 
     30class ReferenceExistsCondition extends ProjectComponent implements Condition { 
     31     
     32    private $refid; 
     33 
     34    public function setRef($id) { 
     35      $this->refid = (string) $id; 
     36    } 
     37 
     38    /** 
     39     * Check whether the reference exists. 
     40     * @throws BuildException 
     41     */ 
     42    public function evaluate()  { 
     43        if ($this->refid === null) { 
     44            throw new BuildException("No ref attribute specified for reference-exists " 
     45                                     . "condition"); 
     46        }         
     47        $refs = $this->project->getReferences(); 
     48        return isset($refs[$this->refid]); 
     49    } 
     50 
     51} 
     52