06.03 php saved
AevumDecessus
Tags add more
 
Note
Put this in a file "whitespace.php" in the vendors/shells folder and run ./cake whitespace to run the check.

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

Modify this Paste