From 850c73d16067a73d0561ecb80428aa298d4bad7d Mon Sep 17 00:00:00 2001 From: paladox Date: Fri, 9 Sep 2016 14:42:15 +0100 Subject: [PATCH 1/7] Update Settings.php --- src/Settings.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Settings.php b/src/Settings.php index 0104417a..8d72b270 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -38,6 +38,12 @@ class Settings */ public $phpExecutable = 'php'; + /** + * Git executable + * @var string + */ + public $OnlyFilesChanged = 'git'; + /** * Check code inside PHP opening short tag excluded[] = $arguments->getNext(); break; + case '-h': + $settings->OnlyFilesChanged = exec($git); + break; + case '-e': $settings->extensions = array_map('trim', explode(',', $arguments->getNext())); break; From 43a45c68eae1477a2244a4c4b58d0b2d05b2be07 Mon Sep 17 00:00:00 2001 From: paladox Date: Fri, 9 Sep 2016 14:55:21 +0100 Subject: [PATCH 2/7] Update Settings.php --- src/Settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Settings.php b/src/Settings.php index 8d72b270..082500a8 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -139,7 +139,7 @@ public static function parseArguments(array $arguments) -m \ --first-parent \ --format=format: \ - -- "${PATH_ARGS[@]}" | egrep -v '^$' || :"; + -- "'*' . array('.php', '.phtml', '.php3', '.php4', '.php5')" | egrep -v '^$' || :"; foreach ($arguments as $argument) { if ($argument{0} !== '-') { From c6f9ef43e32a774c0ec140743937b627e2c84a5d Mon Sep 17 00:00:00 2001 From: paladox Date: Fri, 9 Sep 2016 16:33:19 +0100 Subject: [PATCH 3/7] part 2 --- src/Manager.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Manager.php b/src/Manager.php index 1f38e31b..510ff3ab 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -53,7 +53,7 @@ public function run(Settings $settings = null) $output->writeHeader($phpExecutable->getVersionId(), $settings->parallelJobs, $phpExecutable->getHhvmVersion()); - $files = $this->getFilesFromPaths($settings->paths, $settings->extensions, $settings->excluded); + $files = $this->getFilesFromPaths($settings->paths, $settings->extensions, $settings->excluded, $settings->OnlyFilesChanged); if (empty($files)) { throw new Exception('No file found to check.'); @@ -144,10 +144,11 @@ protected function gitBlame(Result $result, Settings $settings) * @param array $paths * @param array $extensions * @param array $excluded + * @param array $OnlyFilesChanged * @return array * @throws NotExistsPathException */ - protected function getFilesFromPaths(array $paths, array $extensions, array $excluded = array()) + protected function getFilesFromPaths(array $paths, array $extensions, array $excluded = array(), array $OnlyFilesChanged = array() ) { $extensions = array_flip($extensions); $files = array(); @@ -157,8 +158,12 @@ protected function getFilesFromPaths(array $paths, array $extensions, array $exc $files[] = $path; } elseif (is_dir($path)) { $iterator = new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS); - if (!empty($excluded)) { - $iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded); + if (!empty($excluded) && !empty($OnlyFilesChanged)) { + $iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded, $OnlyFilesChanged); + } elseif (!empty($OnlyFilesChanged) ) { + $iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded, $OnlyFilesChanged); + } elseif (!empty($excluded)) { + $iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded, $OnlyFilesChanged); } $iterator = new \RecursiveIteratorIterator( $iterator, @@ -191,15 +196,19 @@ class RecursiveDirectoryFilterIterator extends \RecursiveFilterIterator /** @var array */ private $excluded = array(); + /** @var array */ + private $OnlyFilesChanged = array(); + /** * @param \RecursiveDirectoryIterator $iterator * @param array $excluded */ - public function __construct(\RecursiveDirectoryIterator $iterator, array $excluded) + public function __construct(\RecursiveDirectoryIterator $iterator, array $excluded, array $OnlyFilesChanged) { parent::__construct($iterator); $this->iterator = $iterator; $this->excluded = array_map(array($this, 'getPathname'), $excluded); + $this->OnlyFilesChanged = array_map(array($this, 'getPathname'), $OnlyFilesChanged); } /** From 27dbaec4432a40b8ebfe59b96dc3f911ead642ef Mon Sep 17 00:00:00 2001 From: paladox Date: Sat, 10 Sep 2016 14:05:56 +0100 Subject: [PATCH 4/7] Update --- src/Manager.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Manager.php b/src/Manager.php index 510ff3ab..a6df9545 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -53,7 +53,7 @@ public function run(Settings $settings = null) $output->writeHeader($phpExecutable->getVersionId(), $settings->parallelJobs, $phpExecutable->getHhvmVersion()); - $files = $this->getFilesFromPaths($settings->paths, $settings->extensions, $settings->excluded, $settings->OnlyFilesChanged); + $files = $this->getFilesFromPaths($settings->paths, $settings->extensions, $settings->excluded, $settings->changedFiles); if (empty($files)) { throw new Exception('No file found to check.'); @@ -148,7 +148,7 @@ protected function gitBlame(Result $result, Settings $settings) * @return array * @throws NotExistsPathException */ - protected function getFilesFromPaths(array $paths, array $extensions, array $excluded = array(), array $OnlyFilesChanged = array() ) + protected function getFilesFromPaths(array $paths, array $extensions, array $excluded = array(), array $changedFiles = array() ) { $extensions = array_flip($extensions); $files = array(); @@ -158,12 +158,12 @@ protected function getFilesFromPaths(array $paths, array $extensions, array $exc $files[] = $path; } elseif (is_dir($path)) { $iterator = new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS); - if (!empty($excluded) && !empty($OnlyFilesChanged)) { - $iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded, $OnlyFilesChanged); + if (!empty($excluded) && !empty($changedFiles)) { + $iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded, $changedFiles); } elseif (!empty($OnlyFilesChanged) ) { - $iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded, $OnlyFilesChanged); + $iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded, $changedFiles); } elseif (!empty($excluded)) { - $iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded, $OnlyFilesChanged); + $iterator = new RecursiveDirectoryFilterIterator($iterator, $excluded, $changedFiles); } $iterator = new \RecursiveIteratorIterator( $iterator, @@ -203,12 +203,12 @@ class RecursiveDirectoryFilterIterator extends \RecursiveFilterIterator * @param \RecursiveDirectoryIterator $iterator * @param array $excluded */ - public function __construct(\RecursiveDirectoryIterator $iterator, array $excluded, array $OnlyFilesChanged) + public function __construct(\RecursiveDirectoryIterator $iterator, array $excluded, array $changedFiles) { parent::__construct($iterator); $this->iterator = $iterator; $this->excluded = array_map(array($this, 'getPathname'), $excluded); - $this->OnlyFilesChanged = array_map(array($this, 'getPathname'), $OnlyFilesChanged); + $this->changedFiles = array_map(array($this, 'getPathname'), $changedFiles); } /** From 68af75dc446d8e69586e19427e11882dbfab931b Mon Sep 17 00:00:00 2001 From: paladox Date: Sat, 10 Sep 2016 14:08:17 +0100 Subject: [PATCH 5/7] Update --- src/Settings.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Settings.php b/src/Settings.php index 082500a8..a7abf260 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -42,7 +42,7 @@ class Settings * Git executable * @var string */ - public $OnlyFilesChanged = 'git'; + public $changedFiles = 'git'; /** * Check code inside PHP opening short tag excluded[] = $arguments->getNext(); break; - case '-h': - $settings->OnlyFilesChanged = exec($git); + case '--head': + $settings->changedFiles = exec($git); break; case '-e': From 68b1de89751b65f2e13ef61e124fad9576b61bf0 Mon Sep 17 00:00:00 2001 From: paladox Date: Sat, 10 Sep 2016 14:08:55 +0100 Subject: [PATCH 6/7] Update Manager.php --- src/Manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Manager.php b/src/Manager.php index a6df9545..efd28395 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -197,7 +197,7 @@ class RecursiveDirectoryFilterIterator extends \RecursiveFilterIterator private $excluded = array(); /** @var array */ - private $OnlyFilesChanged = array(); + private $changedFiles = array(); /** * @param \RecursiveDirectoryIterator $iterator From a39753a5c9588fd198aff28970be50c018c7f7e2 Mon Sep 17 00:00:00 2001 From: paladox Date: Sat, 10 Sep 2016 14:10:35 +0100 Subject: [PATCH 7/7] Update Manager.php --- src/Manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Manager.php b/src/Manager.php index efd28395..7f35a31f 100644 --- a/src/Manager.php +++ b/src/Manager.php @@ -144,7 +144,7 @@ protected function gitBlame(Result $result, Settings $settings) * @param array $paths * @param array $extensions * @param array $excluded - * @param array $OnlyFilesChanged + * @param array $changedFiles * @return array * @throws NotExistsPathException */