From 5a642c54043ae589c02778a253501a01a1ebff35 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 3 Oct 2015 20:00:52 +0200 Subject: [PATCH 1/2] fix PathComparator when 0 in path --- src/PathComparator.php | 2 +- tests/PathComparator.test.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PathComparator.php b/src/PathComparator.php index fc0d791..ba27d57 100644 --- a/src/PathComparator.php +++ b/src/PathComparator.php @@ -33,7 +33,7 @@ public function getCommondBase() { private function commonPrefix( $s1, $s2, $i=0 ) { return ( - !empty($s1[$i]) && !empty($s2[$i]) && $s1[$i] == $s2[$i] + $icommonPrefix( $s1, $s2, ++$i ) : $i; } } diff --git a/tests/PathComparator.test.php b/tests/PathComparator.test.php index 4d4f15b..ab25108 100644 --- a/tests/PathComparator.test.php +++ b/tests/PathComparator.test.php @@ -27,6 +27,9 @@ public function directoriesProvider() { ], 'partns' => [ array(__DIR__ . '/../src', __DIR__ . '/../vendor/theseer'), dirname(__DIR__) + ], + 'with0' => [ + [$a=__DIR__.'/_data/parser/trait0.php'], $a ] ]; } From b005810db7200e59d6f8e1883f1ec89757d4c0d8 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 3 Oct 2015 20:08:05 +0200 Subject: [PATCH 2/2] CS --- src/PathComparator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PathComparator.php b/src/PathComparator.php index ba27d57..4e99083 100644 --- a/src/PathComparator.php +++ b/src/PathComparator.php @@ -27,7 +27,7 @@ public function getCommondBase() { foreach($this->directories as $dir) { $result = substr($dir, 0, $this->commonPrefix($result, $dir)); } - return rtrim($result,'/'); + return rtrim($result, '/'); }