當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Path::__toString方法代碼示例

本文整理匯總了PHP中Path::__toString方法的典型用法代碼示例。如果您正苦於以下問題:PHP Path::__toString方法的具體用法?PHP Path::__toString怎麽用?PHP Path::__toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Path的用法示例。


在下文中一共展示了Path::__toString方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRelativePath

 /**
  * {@inheritdoc}
  */
 public function getRelativePath(PathInterface $reference)
 {
     if ($this->sameValueAs($reference)) {
         return '';
     }
     $ref_path = array_values($reference->toArray());
     $this_path = array_values($this->data);
     $filename = array_pop($this_path);
     //retrieve the final consecutive identical segment in the current path
     $index = 0;
     foreach ($ref_path as $offset => $value) {
         if (!isset($this_path[$offset]) || $value != $this_path[$offset]) {
             break;
         }
         $index++;
     }
     //deduce the number of similar segment according to the reference path
     $nb_common_segment = count($ref_path) - $index;
     $nb_segments = array();
     if ($nb_common_segment) {
         $nb_segments = array_fill(0, $nb_common_segment, '..');
     }
     //let's output the relative path using a new Path object
     $res = new Path(array_merge($nb_segments, array_slice($this_path, $index), array($filename)));
     return $res->__toString();
 }
開發者ID:yakamoz-fang,項目名稱:concrete,代碼行數:29,代碼來源:Path.php

示例2: main

 /** Main entry point */
 public function main()
 {
     // Apparently casting to (string) no longer invokes __toString() automatically.
     if (is_object($this->classpath)) {
         $classpath = $this->classpath->__toString();
     }
     if (empty($classpath)) {
         throw new BuildException("Provided classpath was empty.");
     }
     $curr_parts = Phing::explodeIncludePath();
     $add_parts = Phing::explodeIncludePath($classpath);
     $new_parts = array_diff($add_parts, $curr_parts);
     if ($new_parts) {
         $this->updateIncludePath($new_parts, $curr_parts);
     }
 }
開發者ID:xxspartan16,項目名稱:BMS-Market,代碼行數:17,代碼來源:IncludePathTask.php

示例3: main

 /** Main entry point */
 public function main()
 {
     // Apparently casting to (string) no longer invokes __toString() automatically.
     if (is_object($this->classpath)) {
         $classpath = $this->classpath->__toString();
     }
     if (empty($classpath)) {
         throw new BuildException("Provided classpath was empty.");
     }
     $curr_parts = Phing::explodeIncludePath();
     $add_parts = Phing::explodeIncludePath($classpath);
     $new_parts = array_diff($add_parts, $curr_parts);
     if ($new_parts) {
         $this->log("Prepending new include_path components: " . implode(PATH_SEPARATOR, $new_parts), Project::MSG_VERBOSE);
         set_include_path(implode(PATH_SEPARATOR, array_merge($new_parts, $curr_parts)));
     }
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:18,代碼來源:IncludePathTask.php

示例4: testGetChildren

 /**
  *  tests the {@link Montage\Path::getChildren()} method
  */
 public function testGetChildren()
 {
     $base = $this->getFixturePath('Path');
     $instance = new Path($base);
     $test_list = array();
     $test_list[] = array('in' => array('', 1), 'out' => array('files' => array(join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'che.txt'))), 'folders' => array(join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'bar')), join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'foo')))));
     $test_list[] = array('in' => array('#che#', 1), 'out' => array('files' => array(join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'che.txt'))), 'folders' => array()));
     $test_list[] = array('in' => array('#something-not-matching#', 1), 'out' => array('files' => array(), 'folders' => array()));
     $test_list[] = array('in' => array('', -1), 'out' => array('files' => array(join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'bar', '2', '1.txt')), join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'bar', '2', 'monkey.txt')), join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'che.txt')), join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'foo', '1', 'monkey.txt'))), 'folders' => array(join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'bar')), join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'bar', '1')), join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'bar', '2')), join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'bar', '3')), join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'foo')), join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'foo', '1')))));
     $test_list[] = array('in' => array('#che#', -1), 'out' => array('files' => array(join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'che.txt'))), 'folders' => array()));
     $test_list[] = array('in' => array('#1$#', -1), 'out' => array('files' => array(), 'folders' => array(join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'bar', '1')), join(DIRECTORY_SEPARATOR, array($instance->__toString(), 'foo', '1')))));
     $test_list[] = array('in' => array('#nothing-matching#', -1), 'out' => array('files' => array(), 'folders' => array()));
     foreach ($test_list as $key => $test_map) {
         $actual = call_user_func_array(array($instance, 'getChildren'), $test_map['in']);
         $this->assertEquals($test_map['out'], $actual, $key);
     }
     //foreach
 }
開發者ID:Jaymon,項目名稱:Montage,代碼行數:21,代碼來源:PathTest.php


注:本文中的Path::__toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。