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


PHP ParserFactory::create方法代码示例

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


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

示例1: foreach

foreach ($opml->xpath('//outline') as $item) {
    if ((string) $item['language'] == 'en-gb') {
        $feed_parser->add((string) $item['xmlUrl']);
    }
}
$feed_parser->add('http://www.guardian.co.uk/rss');
$feed_parser->add('http://www.guardian.co.uk/rssfeed/0,,11,00.xml');
$feed_parser->add('http://www.guardian.co.uk/rssfeed/0,,12,00.xml');
$feed_parser->add('http://www.guardian.co.uk/rssfeed/0,,5,00.xml');
$feed_parser->add('http://www.guardian.co.uk/rssfeed/0,,24,00.xml');
$feed_parser->add('http://www.guardian.co.uk/rssfeed/0,15065,19,00.xml');
$feed_parser->add('http://www.guardian.co.uk/rssfeed/0,,18,00.xml');
$feed_parser->add('http://www.guardian.co.uk/rssfeed/0,,7,00.xml');
$feed_parser->add('http://english.aljazeera.net/Services/Rss/?PostingId=2007731105943979989');
echo "DONE\n";
$parser_factory = ParserFactory::create();
function prompt($parser, $item, $category, $locations)
{
    echo "\n" . $item->title() . "\n";
    echo $locations[0]['name'] . ' <-> ' . $locations[1]['name'] . "\n";
    if ($category) {
        echo $category['name'] . " ok?\n";
    }
    while (true) {
        $in = readline('> ');
        if ($in == 'q') {
            return;
        } elseif ($in == 'm') {
            echo $item->title() . "\n";
            echo $item->guid() . "\n";
            echo $item->description() . "\n";
开发者ID:robyoung,项目名称:war-and-peace,代码行数:31,代码来源:add-items.php

示例2: processFiles

 /**
  * This method will process all files that can be found in the given input
  * path. It will apply rules defined in the comma-separated <b>$ruleSets</b>
  * argument. The result will be passed to all given renderer instances.
  *
  * @param string $inputPath
  * @param string $ruleSets
  * @param \PHPMD\AbstractRenderer[] $renderers
  * @param \PHPMD\RuleSetFactory $ruleSetFactory
  * @return void
  */
 public function processFiles($inputPath, $ruleSets, array $renderers, RuleSetFactory $ruleSetFactory)
 {
     // Merge parsed excludes
     $this->ignorePatterns = array_merge($this->ignorePatterns, $ruleSetFactory->getIgnorePattern($ruleSets));
     $this->input = $inputPath;
     $report = new Report();
     $factory = new ParserFactory();
     $parser = $factory->create($this);
     foreach ($ruleSetFactory->createRuleSets($ruleSets) as $ruleSet) {
         $parser->addRuleSet($ruleSet);
     }
     $report->start();
     $parser->parse($report);
     $report->end();
     foreach ($renderers as $renderer) {
         $renderer->start();
     }
     foreach ($renderers as $renderer) {
         $renderer->renderReport($report);
     }
     foreach ($renderers as $renderer) {
         $renderer->end();
     }
     $this->violations = !$report->isEmpty();
 }
开发者ID:flavius,项目名称:phpmd,代码行数:36,代码来源:PHPMD.php

示例3: testFactoryConfiguresFileExtensions

 /**
  * testFactoryConfiguresFileExtensions
  *
  * @return void
  */
 public function testFactoryConfiguresFileExtensions()
 {
     $factory = new ParserFactory();
     $uri = $this->createFileUri('ParserFactory/File/Test.php');
     $phpmd = $this->getMock('PHPMD\\PHPMD', array('getFileExtensions', 'getInput'));
     $phpmd->expects($this->exactly(2))->method('getFileExtensions')->will($this->returnValue(array('.php')));
     $phpmd->expects($this->once())->method('getInput')->will($this->returnValue($uri));
     $factory->create($phpmd);
 }
开发者ID:flavius,项目名称:phpmd,代码行数:14,代码来源:ParserFactoryTest.php


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