当前位置: 首页>>代码示例>>PHP>>正文


PHP ezcBaseFile::calculateRelativePath方法代码示例

本文整理汇总了PHP中ezcBaseFile::calculateRelativePath方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcBaseFile::calculateRelativePath方法的具体用法?PHP ezcBaseFile::calculateRelativePath怎么用?PHP ezcBaseFile::calculateRelativePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ezcBaseFile的用法示例。


在下文中一共展示了ezcBaseFile::calculateRelativePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRelative3

 public function testRelative3()
 {
     $result = ezcBaseFile::calculateRelativePath('/foo/1/2/php.php', '/foo/bar');
     self::assertEquals('..' . DIRECTORY_SEPARATOR . '1' . DIRECTORY_SEPARATOR . '2' . DIRECTORY_SEPARATOR . 'php.php', $result);
     $result = ezcBaseFile::calculateRelativePath('/foo/bar/php.php', '/foo/bar');
     self::assertEquals('php.php', $result);
     $result = ezcBaseFile::calculateRelativePath('/php.php', '/foo/bar/1/2');
     self::assertEquals('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'php.php', $result);
     $result = ezcBaseFile::calculateRelativePath('/bar/php.php', '/foo/bar/1/2');
     self::assertEquals('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR . 'php.php', $result);
 }
开发者ID:andikoller,项目名称:FHC-3.0-FHBGLD,代码行数:11,代码来源:file_calculate_relative_path_test.php

示例2: getClassFileList

 /**
  * Extracts class information from PHP sourcecode.
  * @return array (className=>filename)
  */
 protected function getClassFileList($fileList, $mode)
 {
     $retArray = array();
     $this->log("Searching for classes (tokenizing).");
     $statArray = array('nFiles' => count($fileList), 'classCount' => 0, 'classAdded' => 0);
     $this->setStatArray(self::OUTPUT_PROGRESS_PHASE2, $statArray);
     if (count($fileList)) {
         $this->startProgressOutput(self::OUTPUT_PROGRESS_PHASE2);
         // Compatibility with PHP 5.2 where T_NAMESPACE constant is not available
         // Assigning the constant value to $tNamespace
         // 377 is the value for T_NAMESPACE in PHP 5.3.x
         $tNamespace = defined('T_NAMESPACE') ? T_NAMESPACE : self::UNDEFINED_TOKEN;
         // Traits support, see http://issues.ez.no/19028
         $tTrait = defined('T_TRAIT') ? T_TRAIT : self::UNDEFINED_TOKEN;
         foreach ($fileList as $file) {
             $this->updateProgressOutput(self::OUTPUT_PROGRESS_PHASE2);
             if ($mode === self::MODE_SINGLE_EXTENSION) {
                 $file = getcwd() . DIRECTORY_SEPARATOR . $this->options->basePath . DIRECTORY_SEPARATOR . $file;
             }
             $tokens = @token_get_all(file_get_contents($file));
             $namespace = null;
             foreach ($tokens as $key => $token) {
                 if (is_array($token)) {
                     switch ($token[0]) {
                         case self::UNDEFINED_TOKEN:
                             // Unsupported token, do nothing
                             break;
                             // Store namespace name, if applicable, to concatenate with class name
                         // Store namespace name, if applicable, to concatenate with class name
                         case $tNamespace:
                             // NAMESPACE_TOKEN - WHITESPACE_TOKEN - TEXT_TOKENS (containing namespace name)
                             $offset = $key + 2;
                             $namespace = "";
                             while ($tokens[$offset] !== ";" && $tokens[$offset] !== "{") {
                                 if (is_array($tokens[$offset])) {
                                     $namespace .= $tokens[$offset][1];
                                 }
                                 $offset++;
                             }
                             $namespace = trim(addcslashes($namespace, '\\'));
                             break;
                         case T_CLASS:
                         case T_INTERFACE:
                         case $tTrait:
                             // Increment stat for found class.
                             $this->incrementProgressStat(self::OUTPUT_PROGRESS_PHASE2, 'classCount');
                             // CLASS_TOKEN - WHITESPACE_TOKEN - TEXT_TOKEN (containing class name)
                             $className = $tokens[$key + 2][1];
                             if ($namespace !== null) {
                                 $className = "{$namespace}\\\\{$className}";
                             }
                             $filePath = $file;
                             if ($mode === self::MODE_SINGLE_EXTENSION) {
                                 $filePath = ezcBaseFile::calculateRelativePath($filePath, getcwd() . DIRECTORY_SEPARATOR . $this->options->basePath);
                             }
                             // make sure we store cross-platform file system paths,
                             // using a forward slash as directory separator
                             if (DIRECTORY_SEPARATOR != '/') {
                                 $filePath = str_replace(DIRECTORY_SEPARATOR, '/', $filePath);
                             }
                             // Here there are two code paths.
                             // MODE_KERNEL_OVERRIDE will only add a class if
                             // it exists in the MODE_KERNEL autoload array.
                             // All other modes will only add a class if the
                             // class name is unique.
                             $addClass = $this->classCanBeAdded($className, $filePath, $mode, $retArray);
                             if ($addClass) {
                                 // increment stat for actually added number of classes.
                                 $this->incrementProgressStat(self::OUTPUT_PROGRESS_PHASE2, 'classAdded');
                                 $retArray[$className] = $filePath;
                             }
                             break;
                     }
                 }
             }
         }
         $this->stopProgressOutput(self::OUTPUT_PROGRESS_PHASE2);
         ksort($retArray);
     }
     if ($this->output !== null) {
         extract($this->getStatArray(self::OUTPUT_PROGRESS_PHASE2));
         $this->log("Found {$classCount} classes, added {$classAdded} of them to the autoload array.");
     }
     return $retArray;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:89,代码来源:ezautoloadgenerator.php

示例3: testEqual

 public function testEqual()
 {
     self::assertEquals('.', ezcBaseFile::calculateRelativePath('/bar/php.php', '/bar/php.php'));
     self::assertEquals('.', ezcBaseFile::calculateRelativePath('C:\\workspace\\xxx_upgrade', 'C:\\workspace\\xxx_upgrade'));
 }
开发者ID:corcre,项目名称:elabftw,代码行数:5,代码来源:file_calculate_relative_path_test.php

示例4: getClassFileList

 /**
  * Extracts class information from PHP sourcecode.
  * @return array (className=>filename)
  */
 protected function getClassFileList($fileList, $mode)
 {
     $retArray = array();
     $this->log("Searching for classes (tokenizing).");
     $statArray = array('nFiles' => count($fileList), 'classCount' => 0, 'classAdded' => 0);
     $this->setStatArray(self::OUTPUT_PROGRESS_PHASE2, $statArray);
     $this->startProgressOutput(self::OUTPUT_PROGRESS_PHASE2);
     foreach ($fileList as $file) {
         $this->updateProgressOutput(self::OUTPUT_PROGRESS_PHASE2);
         if ($mode === self::MODE_SINGLE_EXTENSION) {
             $file = getcwd() . DIRECTORY_SEPARATOR . $this->options->basePath . DIRECTORY_SEPARATOR . $file;
         }
         $tokens = @token_get_all(file_get_contents($file));
         foreach ($tokens as $key => $token) {
             if (is_array($token)) {
                 switch ($token[0]) {
                     case T_CLASS:
                     case T_INTERFACE:
                         // Increment stat for found class.
                         $this->incrementProgressStat(self::OUTPUT_PROGRESS_PHASE2, 'classCount');
                         // CLASS_TOKEN - WHITESPACE_TOKEN - TEXT_TOKEN (containing class name)
                         $className = $tokens[$key + 2][1];
                         $filePath = $file;
                         if ($mode === self::MODE_SINGLE_EXTENSION) {
                             $filePath = ezcBaseFile::calculateRelativePath($filePath, getcwd() . DIRECTORY_SEPARATOR . $this->options->basePath);
                         }
                         // make sure we store cross-platform file system paths,
                         // using a forward slash as directory separator
                         if (DIRECTORY_SEPARATOR != '/') {
                             $filePath = str_replace(DIRECTORY_SEPARATOR, '/', $filePath);
                         }
                         // Here there are two code paths.
                         // MODE_KERNEL_OVERRIDE will only add a class if
                         // it exists in the MODE_KERNEL autoload array.
                         // All other modes will only add a class if the
                         // class name is unique.
                         $addClass = $this->classCanBeAdded($className, $filePath, $mode, $retArray);
                         if ($addClass) {
                             // increment stat for actually added number of classes.
                             $this->incrementProgressStat(self::OUTPUT_PROGRESS_PHASE2, 'classAdded');
                             $retArray[$className] = $filePath;
                         }
                         break;
                 }
             }
         }
     }
     $this->stopProgressOutput(self::OUTPUT_PROGRESS_PHASE2);
     if ($this->output !== null) {
         extract($this->getStatArray(self::OUTPUT_PROGRESS_PHASE2));
         $this->log("Found {$classCount} classes, added {$classAdded} of them to the autoload array.");
     }
     ksort($retArray);
     return $retArray;
 }
开发者ID:runelangseid,项目名称:ezpublish,代码行数:59,代码来源:ezautoloadgenerator.php


注:本文中的ezcBaseFile::calculateRelativePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。