06.03 php saved
davidpersson
Tags add more
check whitespace new  
Note
Put this in a file "whitespace.php" in the vendors/shells folder and run ./cake whitespace to run the check.
  1. App::import('Core',array('Folder'));
  2.  
  3. class WhitespaceShell extends Shell
  4. {
  5.     var $tasks = array();
  6.     var $uses = array();
  7.        
  8.    
  9.     function main()
  10.     {
  11.         $App = new Folder(APP);
  12.        
  13.         $r = $App->findRecursive('.*\.php');
  14.         $this->out("Checking *.php in ".APP);
  15.         foreach($r as $file) {
  16.             $c = file_get_contents($file);
  17.             if(preg_match('/^[\n\r|\n\r|\n|\r|\s]+\<\?php/',$c)) {
  18.                 $this->out('!!!contains leading whitespaces: '.$this->shortPath($file));
  19.             }
  20.             if(preg_match('/\?\>[\n\r|\n\r|\n|\r|\s]+$/',$c)) {
  21.                 $this->out('!!!contains trailing whitespaces: '.$this->shortPath($file));
  22.             }
  23.            
  24.            
  25.         }
  26.        
  27.     }
  28.  
  29. }
Parsed in 0.050 seconds, using GeSHi 1.0.7.14

Modify this Paste