PHP_CodeSniffer
[ class tree: PHP_CodeSniffer ] [ index: PHP_CodeSniffer ] [ all elements ]

Source for file GitModified.php

Documentation is available at GitModified.php

  1. <?php
  2. /**
  3.  * A filter to only include files that have been modified or added in a Git repository.
  4.  *
  5.  * @author    Greg Sherwood <gsherwood@squiz.net>
  6.  * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
  7.  * @license   https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
  8.  */
  9.  
  10. namespace PHP_CodeSniffer\Filters;
  11.  
  12. use PHP_CodeSniffer\Util;
  13.  
  14. class GitModified extends ExactMatch
  15. {
  16.  
  17.  
  18.     /**
  19.      * Get a list of blacklisted file paths.
  20.      *
  21.      * @return array 
  22.      */
  23.     protected function getBlacklist()
  24.     {
  25.         return array();
  26.  
  27.     }//end getBlacklist()
  28.  
  29.  
  30.     /**
  31.      * Get a list of whitelisted file paths.
  32.      *
  33.      * @return array 
  34.      */
  35.     protected function getWhitelist()
  36.     {
  37.         $modified = array();
  38.  
  39.         $cmd    'git ls-files -o -m --exclude-standard -- '.escapeshellarg($this->basedir);
  40.         $output = array();
  41.         exec($cmd$output);
  42.  
  43.         $basedir $this->basedir;
  44.         if (is_dir($basedir=== false{
  45.             $basedir dirname($basedir);
  46.         }
  47.  
  48.         foreach ($output as $path{
  49.             $path = Util\Common::realpath($path);
  50.             do {
  51.                 $modified[$path= true;
  52.                 $path            dirname($path);
  53.             while ($path !== $basedir);
  54.         }
  55.  
  56.         return $modified;
  57.  
  58.     }//end getWhitelist()
  59.  
  60.  
  61. }//end class

Documentation generated on Mon, 11 Mar 2019 15:27:33 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.