Skip to content

Commit

Permalink
Merge pull request #66 from remicollet/issue-zero
Browse files Browse the repository at this point in the history
fix PathComparator when 0 in path
  • Loading branch information
theseer committed Oct 3, 2015
2 parents 63813ec + b005810 commit a37eeae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/PathComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function getCommondBase() {
foreach($this->directories as $dir) {
$result = substr($dir, 0, $this->commonPrefix($result, $dir));
}
return rtrim($result,'/');
return rtrim($result, '/');
}


private function commonPrefix( $s1, $s2, $i=0 ) {
return (
!empty($s1[$i]) && !empty($s2[$i]) && $s1[$i] == $s2[$i]
$i<strlen($s1) && $i<strlen($s2) && $s1[$i] == $s2[$i]
) ? $this->commonPrefix( $s1, $s2, ++$i ) : $i;
}
}
Expand Down
3 changes: 3 additions & 0 deletions tests/PathComparator.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function directoriesProvider() {
],
'partns' => [
array(__DIR__ . '/../src', __DIR__ . '/../vendor/theseer'), dirname(__DIR__)
],
'with0' => [
[$a=__DIR__.'/_data/parser/trait0.php'], $a
]
];
}
Expand Down

0 comments on commit a37eeae

Please sign in to comment.