From 60d7515b35c7f4d8249b30101a816ea48631edee Mon Sep 17 00:00:00 2001 From: smetdenis Date: Mon, 7 Mar 2016 16:46:14 +0600 Subject: [PATCH] PHP CS --- src/Path.php | 14 +++++++------- tests/performanceTest.php | 6 ++---- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Path.php b/src/Path.php index b8ddb78..eddbb7b 100644 --- a/src/Path.php +++ b/src/Path.php @@ -205,7 +205,7 @@ public function get($source) * Get absolute path to a file or a directory. * * @param $source (example: "default:file.txt") - * @return array() + * @return array */ public function glob($source) { @@ -351,7 +351,7 @@ public function url($source, $full = true) */ public function rel($source) { - $fullpath = $this->get($source); + $fullpath = (string)$this->get($source); return FS::getRelative($fullpath, $this->_root, '/'); } @@ -363,7 +363,7 @@ public function rel($source) */ public function relGlob($source) { - $list = $this->glob($source); + $list = (array)$this->glob($source); foreach ($list as $key => $item) { $list[$key] = FS::getRelative($item, $this->_root, '/'); } @@ -381,14 +381,14 @@ public function relGlob($source) */ protected function _addNewPath($path, $alias, $mode) { - $path = $this->_cleanPath($path); - if ($path !== null) { + if ($cleanPath = $this->_cleanPath($path)) { + if ($mode == self::MOD_PREPEND) { - array_unshift($this->_paths[$alias], $path); + array_unshift($this->_paths[$alias], $cleanPath); } if ($mode == self::MOD_APPEND) { - array_push($this->_paths[$alias], $path); + array_push($this->_paths[$alias], $cleanPath); } } } diff --git a/tests/performanceTest.php b/tests/performanceTest.php index 42f689c..b91a8df 100644 --- a/tests/performanceTest.php +++ b/tests/performanceTest.php @@ -71,7 +71,7 @@ public function testCompareWithRealpath() return $result; }, - ), array('count' => 500, 'name' => 'Compare with realpath')); + ), array('count' => 1000, 'name' => 'Compare with realpath')); } public function testPathResolver() @@ -83,7 +83,7 @@ public function testPathResolver() $virtPath->set('default', $root); runBench(array( - 'new path (new)' => function () use ($fs, $root) { + 'new path (new obj and dir)' => function () use ($fs, $root) { $newDir = $root . mt_rand(); $fs->mkdir($newDir); @@ -94,8 +94,6 @@ public function testPathResolver() $result = $virtPath->get('default:'); // end - $fs->remove($result); - return $result; }, 'same path (new)' => function () use ($fs, $root) {