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


PHP Libraries::find方法代码示例

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


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

示例1: run

 /**
  * Main method.
  *
  * @param string $path Absolute path to file or directory.
  * @return boolean
  */
 public function run()
 {
     $path = $this->request->action;
     if (!($path = realpath($path))) {
         $this->error('Not a valid path.');
         return false;
     }
     if (!($library = $this->_library($path))) {
         $this->error("No library registered for path `{$path}`.");
         return false;
     }
     $classes = Libraries::find($library, array('recursive' => true, 'exclude' => '/tests|resources|webroot|index$|^app\\\\config|^app\\\\views|Exception$/'));
     $tests = array();
     foreach (Group::all() as $test) {
         $class = preg_replace('/(tests\\\\[a-z]+\\\\|Test$)/', null, $test);
         $tests[$class] = $test;
     }
     foreach ($classes as $class) {
         $coverage = null;
         if ($hasTest = isset($tests[$class])) {
             $report = Dispatcher::run($tests[$class], array('reporter' => 'console', 'format' => 'txt', 'filters' => array('Coverage')));
             $coverage = $report->results['filters']['lithium\\test\\filter\\Coverage'];
             $coverage = isset($coverage[$class]) ? $coverage[$class]['percentage'] : null;
         }
         $this->out(sprintf('%10s | %7s | %s', $hasTest ? 'has test' : 'no test', is_numeric($coverage) ? sprintf('%.2f%%', $coverage) : 'n/a', $class));
     }
 }
开发者ID:ncud,项目名称:sagalaya,代码行数:33,代码来源:Covered.php

示例2: add

 /**
  * Add a tests to the group
  *
  * @param string $test
  * @param string $options
  * @return array
  */
 public function add($test = null, $options = array())
 {
     $callback = function ($test) {
         if (empty($test)) {
             return array();
         }
         if (is_object($test) && $test instanceof \lithium\test\Unit) {
             return array(get_class($test));
         }
         if (is_string($test)) {
             if ($test[0] != '\\') {
                 $test = "lithium\\tests\\cases\\{$test}";
             }
             if (preg_match("/Test/", $test)) {
                 return array($test);
             }
             $parts = array_filter(explode("\\", $test));
             $library = array_shift($parts);
             $test = Libraries::find($library, array('recursive' => true, 'path' => '/' . join('/', $parts), 'filter' => '/cases|intergration|functional/'));
             return (array) $test;
         }
         return (array) $test;
     };
     if (is_array($test)) {
         foreach ($test as $t) {
             $this->_items = array_filter(array_merge($this->_items, $callback($t)));
         }
         return $this->_items;
     }
     return $this->_items = array_merge($this->_items, $callback($test));
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:38,代码来源:Group.php

示例3: run

 public function run($library = 'lithium')
 {
     $libs = Libraries::find($library, array('recursive' => true));
     $files = array();
     foreach ((array) $libs as $lib) {
         $file = Libraries::path($lib);
         $this->_display($file);
     }
 }
开发者ID:rmarscher,项目名称:li3_docs,代码行数:9,代码来源:Todo.php

示例4: run

 public function run()
 {
     $classes = Libraries::find(true, array('exclude' => "/webroot|index\$|^app\\\\config|^app\\\\views/", 'recursive' => true));
     foreach ($classes as $class) {
         $path = Libraries::path($class);
         $contents = explode("\n", file_get_contents($path));
         $contents = $this->_header($contents);
         if (file_put_contents($path, implode("\n", $contents))) {
             $this->out($path . ' written');
         }
     }
 }
开发者ID:unionofrad,项目名称:li3_docs,代码行数:12,代码来源:Generator.php

示例5: harvest

 public static function harvest()
 {
     $extractor = $this->_classes['extractor'];
     $results = array();
     foreach (Libraries::get() as $library => $info) {
         $libFiles = Libraries::find($library, array('recursive' => true, 'exclude' => '/mocks|tests|libraries/'));
         foreach ($libFiles as $file) {
             $this->out("\n" . $file);
             $fileData = $extractor::get($library, $file);
             $results = array_merge(static::_harvestMethods($fileData), static::_harvestProperties($fileData), array(static::_harvestClass($fileData)));
         }
     }
     return new Collection(array('data' => $results));
 }
开发者ID:unionofrad,项目名称:li3_docs,代码行数:14,代码来源:Symbols.php

示例6: read

 /**
  * Extracts data from files within configured path recursively.
  *
  * @param string $category Dot-delimited category.
  * @param string $locale A locale identifier.
  * @param string $scope The scope for the current operation.
  * @return mixed
  */
 public function read($category, $locale, $scope)
 {
     if ($scope != $this->_config['scope']) {
         return null;
     }
     $library = Libraries::get($this->_config['library']);
     $data = array();
     $classes = Libraries::find($this->_config['library'], array('recursive' => true, 'exclude' => '/\\w+Test$|Mock+\\w|webroot|index$|^app\\\\config|^\\w+\\\\views\\/|\\./'));
     foreach ($classes as $class) {
         if (preg_match('/\\\\(libraries|plugins)\\\\/', $class)) {
             continue;
         }
         $data += $this->_parseClass($class);
     }
     return $data;
 }
开发者ID:rmarscher,项目名称:li3_docs,代码行数:24,代码来源:Docs.php

示例7: run

 /**
  * Main command logic.
  *
  * @return void
  */
 public function run()
 {
     $this->_readyTables();
     $extractor = $this->_classes['extractor'];
     $libraries = Libraries::get();
     foreach ($libraries as $library => $info) {
         $this->header($library);
         $libFiles = Libraries::find($library, array('recursive' => true, 'exclude' => '/mocks|tests|libraries/'));
         foreach ($libFiles as $file) {
             $this->out("\n" . $file);
             $fileData = $extractor::get($library, $file);
             $this->_harvestMethods($fileData);
             $this->_harvestProperties($fileData);
             $this->_harvestClass($fileData);
         }
         $this->out("\n\n");
     }
     $this->out("\n\n");
 }
开发者ID:rmarscher,项目名称:li3_docs,代码行数:24,代码来源:Harvest.php

示例8: _affected

 /**
  * Returns all classes directly depending on a given class.
  *
  * @param string $dependency The class name to use as a dependency.
  * @param string $exclude Regex path exclusion filter.
  * @return array Classes having a direct dependency on `$dependency`. May contain duplicates.
  */
 protected static function _affected($dependency, $exclude = null)
 {
     $exclude = $exclude ?: '/(tests|webroot|resources|libraries|plugins)/';
     $classes = Libraries::find(true, compact('exclude') + array('recursive' => true));
     $dependency = ltrim($dependency, '\\');
     $affected = array();
     foreach ($classes as $class) {
         if (isset(static::$_cachedDepends[$class])) {
             $depends = static::$_cachedDepends[$class];
         } else {
             $depends = Inspector::dependencies($class);
             $depends = array_map(function ($c) {
                 return ltrim($c, '\\');
             }, $depends);
             static::$_cachedDepends[$class] = $depends;
         }
         if (in_array($dependency, $depends)) {
             $affected[] = $class;
         }
     }
     return $affected;
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:29,代码来源:Affected.php

示例9: _children

 protected static function _children($library, $path)
 {
     $result = array();
     $types = array('namespace' => array('namespaces' => true), 'class' => array('namespaces' => false), 'file' => array('namespaces' => false, 'filter' => false, 'preFilter' => false));
     foreach ($types as $type => $options) {
         foreach (Libraries::find($library, compact('path') + $options) as $child) {
             $result += array($child => $type);
         }
     }
     return $result;
 }
开发者ID:rapzo,项目名称:li3_docs,代码行数:11,代码来源:Extractor.php

示例10: missing

 /**
  * Shows which classes are un-tested.
  *
  * @return void
  */
 public function missing()
 {
     $this->header('Classes with no test case');
     $classes = Libraries::find(true, array('recursive' => true, 'exclude' => '/\\w+Test$|webroot|index$|^app\\\\config|^app\\\\views/'));
     $tests = Group::all();
     $classes = array_diff($classes, $tests);
     sort($classes);
     $this->out($classes);
 }
开发者ID:EHER,项目名称:monopolis,代码行数:14,代码来源:Test.php

示例11: testLocateWithLithiumLibrary

 public function testLocateWithLithiumLibrary()
 {
     $expected = (array) Libraries::find('lithium', array('path' => '/tests', 'preFilter' => '/[A-Z][A-Za-z0-9]+\\Test\\./', 'recursive' => true, 'filter' => '/cases|integration|functional|mocks/'));
     $result = (array) Libraries::locate("tests", null, array('library' => 'lithium'));
     $this->assertEqual($expected, $result);
 }
开发者ID:rmarscher,项目名称:lithium,代码行数:6,代码来源:LibrariesTest.php

示例12: testAddTestAppGroup

 public function testAddTestAppGroup()
 {
     $testApp = Libraries::get(true, 'resources') . '/tmp/tests/test_app';
     mkdir($testApp, 0777, true);
     Libraries::add('test_app', array('path' => $testApp));
     mkdir($testApp . '/tests/cases/models', 0777, true);
     file_put_contents($testApp . '/tests/cases/models/UserTest.php', "<?php namespace test_app\\tests\\cases\\models;\n\n\t\t\tclass UserTest extends \\lithium\\test\\Unit { public function testMe() {\n\t\t\t\t\$this->assertTrue(true);\n\t\t\t}}");
     Libraries::cache(false);
     $expected = (array) Libraries::find('test_app', array('recursive' => true, 'path' => '/tests', 'filter' => '/cases|integration|functional/'));
     Libraries::cache(false);
     $group = new Group();
     $result = $group->add('test_app');
     $this->assertEqual($expected, $result);
     Libraries::cache(false);
     $this->_cleanUp();
 }
开发者ID:newmight2015,项目名称:Blockchain-2,代码行数:16,代码来源:GroupTest.php

示例13: _resolve

 /**
  * Resolves a unit test class (or classes) from a class or namespace path string.
  *
  * @param string $test The path string in which to find the test case(s). This may be a
  *               library, a namespace, or a fully-namespaced class reference.
  * @return array Returns an array containing one or more fully-namespaced class references to
  *               unit tests.
  */
 protected function _resolve($test)
 {
     if (strpos($test, '\\') === false && Libraries::get($test)) {
         return (array) Libraries::find($test, array('recursive' => true, 'filter' => '/(cases|integration|functional)\\\\.*Test$/', 'exclude' => '/tests\\\\mocks/'));
     }
     if (!($test = trim($test, '\\'))) {
         return array();
     }
     list($library, $path) = explode('\\', $test, 2) + array($test, null);
     return (array) Libraries::find($library, array('recursive' => true, 'path' => '/' . str_replace('\\', '/', $path), 'filter' => '/(cases|integration|functional)\\\\.*Test$/', 'exclude' => strstr($test, 'tests\\mocks') ? '' : '/tests\\\\mocks/'));
 }
开发者ID:fedeisas,项目名称:lithium,代码行数:19,代码来源:Group.php

示例14: testFindWithOptions

 public function testFindWithOptions()
 {
     $result = Libraries::find('lithium', array('path' => '/console/command/create/template', 'namespaces' => false, 'suffix' => false, 'filter' => false, 'exclude' => false, 'format' => function ($file, $config) {
         return basename($file);
     }));
     $this->assertTrue(count($result) > 3);
     $this->assertTrue(array_search('controller.txt.php', $result));
     $this->assertTrue(array_search('model.txt.php', $result));
     $this->assertTrue(array_search('plugin.phar.gz', $result));
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:10,代码来源:LibrariesTest.php

示例15: _resolve

 /**
  * Resolves a unit test class (or classes) from a class or namespace path string.
  *
  * @param string $test The path string in which to find the test case(s). This may be a
  *               library, a namespace, or a fully-namespaced class reference.
  * @return array Returns an array containing one or more fully-namespaced class references to
  *               unit tests.
  */
 protected function _resolve($test)
 {
     if (strpos($test, '\\') === false && Libraries::get($test)) {
         return (array) Libraries::find($test, array('recursive' => true, 'filter' => '/cases|integration|functional/'));
     }
     if (preg_match("/Test/", $test)) {
         return array($test);
     }
     if (!($test = trim($test, '\\'))) {
         return array();
     }
     list($library, $path) = explode('\\', $test, 2) + array($test, null);
     return (array) Libraries::find($library, array('recursive' => true, 'path' => '/' . str_replace('\\', '/', $path), 'filter' => '/cases|integration|functional/'));
 }
开发者ID:newmight2015,项目名称:Blockchain-2,代码行数:22,代码来源:Group.php


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