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

Modify this Paste