当前位置: 首页>>代码示例>>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;未经允许,请勿转载。