Ticket #207: phing-lint-interpreter.diff

File phing-lint-interpreter.diff, 2.4 kB (added by Markus Fischer <markus@fischer.name>, 7 months ago)

Add php.command property, have PhpLintTask take advantage of it and provide new interpreter attribute, updated docs.

  • classes/phing/Phing.php

    old new  
    10991107                } 
    11001108 
    11011109                self::setProperty('php.classpath', PHP_CLASSPATH); 
     1110                self::setProperty('php.command', getenv('PHP_COMMAND')); 
    11021111 
    11031112                // try to determine the host filesystem and set system property 
    11041113                // used by Fileself::getFileSystem to instantiate the correct 
  • docs/phing_guide/book/chapters/appendixes/AppendixC-OptionalTasks.html

    old new  
    11971197      <td>n/a</td> 
    11981198      <td>No</td> 
    11991199    </tr> 
     1200    <tr> 
     1201      <td>interpreter</td> 
     1202      <td>string</td> 
     1203      <td>Path to alternative PHP interpreter</td> 
     1204      <td>Defaults to the <tt>${php.command}</tt> property which is the 
     1205          interpreter used to execute phing itself.</td> 
     1206      <td>No</td> 
     1207    </tr> 
    12001208  </tbody> 
    12011209</table> 
    12021210 
  • classes/phing/tasks/ext/PhpLintTask.php

    old new  
    3737        protected $haltOnFailure = false; 
    3838        protected $hasErrors = false; 
    3939    private $badFiles = array(); 
     40        protected $interpreter = ''; // php interpreter to use for linting 
    4041 
     42    /** 
     43     * Initialize the interpreter with the Phing property 
     44     */ 
     45    public function __construct() { 
     46        $this->setInterpreter(Phing::getProperty('php.command')); 
     47    } 
     48 
    4149        /** 
     50         * Override default php interpreter 
     51         * @todo        Do some sort of checking if the path is correct but would  
     52         *                      require traversing the systems executeable path too 
     53         * @param       string  $sPhp 
     54         */ 
     55        public function setInterpreter($sPhp) { 
     56                $this->Interpreter = $sPhp; 
     57        } 
     58 
     59        /** 
    4260         * The haltonfailure property 
    4361         * @param boolean $aValue 
    4462         */ 
     
    105123         * @return void 
    106124         */ 
    107125        protected function lint($file) { 
    108                 $command = 'php -l '; 
     126        $command = $this->Interpreter == '' 
     127            ? 'php' 
     128            : $this->Interpreter; 
     129        $command .= ' -l '; 
    109130                if(file_exists($file)) { 
    110131                        if(is_readable($file)) { 
    111132                                $messages = array();