示例#1
0
文件: PathTest.php 项目: crodas/path
 public function testPaths()
 {
     $path = Path::getRelative(__FILE__, __DIR__);
     $this->assertEquals($path, "/tests/PathTest.php");
     $path = Path::getRelative(__FILE__, __FILE__);
     $this->assertEquals($path, "/PathTest.php");
     $path = Path::getRelative(__FILE__, __DIR__ . "/../lib/crodas/Path.php");
     $this->assertEquals($path, "/../../tests/PathTest.php");
 }
示例#2
0
 public static function getRelativePath($dir1, $dir2 = NULL)
 {
     if (empty($dir2)) {
         $dir2 = self::$cdir;
     }
     if (substr($dir1, 0, 4) == "/../") {
         // already relative path
         return $dir1;
     }
     return Path::getRelative($dir1, $dir2);
 }
示例#3
0
文件: File.php 项目: crodas/notoj
 public function __construct($filePath, $parser = null)
 {
     $this->remember = Remember::ns('notoj');
     $files = array();
     foreach ((array) $filePath as $file) {
         if (!is_file($file) || !is_readable($file)) {
             throw new \RuntimeException("{$filePath} is not a file or cannot be read");
         }
         $files[] = Path::normalize($file);
     }
     $this->files = $files;
     $this->annotations = new Annotations();
     foreach ((array) $files as $file) {
         $this->doParse($file, $parser);
     }
 }
示例#4
0
 protected function getTemplateArgs($file = "", $default = array())
 {
     $args = array('classes', 'relative', 'deps', 'include_psr0', 'stats', 'hasTraits', 'hasInterface', 'includes');
     $return = array();
     foreach ($args as $arg) {
         $return[$arg] = array_key_exists($arg, $default) ? $default[$arg] : $this->{$arg};
     }
     $return['relative'] = $return['relative'] && !empty($file);
     if ($return['relative']) {
         foreach ($return['classes'] as $class => $fileClass) {
             $return['classes'][$class][0] = Path::getRelative($fileClass[0], $file);
         }
         foreach ($return['includes'] as $id => $include) {
             $return['includes'][$id] = Path::getRelative($include, $file);
         }
     }
     return $return;
 }