首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ApiGen 5支持多个文件扩展名吗?

ApiGen 5支持多个文件扩展名吗?
EN

Stack Overflow用户
提问于 2017-07-27 18:20:43
回答 1查看 55关注 0票数 1

我使用的是ApiGen 5.0.0-RC3,我不知道如何让它搜索.class文件和.inc文件以及.php文件。

我的问题有两个:第一,是否有可能让ApiGen识别.class文件;第二,如果有可能,人们将如何处理?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-30 22:40:28

我找到了一个方法..。但还是挺烦人的。我把它放在这里是希望它能帮助其他人。

解决方案实际上不是在ApiGen中,而是在漫游/更好的反射中。具体来说,在文件src/SourceLocator/Type/FileIteratorSourceLocator.php中,在方法getAggregatedSourceLocator中,在匿名函数中。

取代:

代码语言:javascript
复制
private function getAggregatedSourceLocator() : AggregateSourceLocator
{
    return $this->aggregateSourceLocator ?: new AggregateSourceLocator(array_values(array_filter(array_map(
        function (\SplFileInfo $item) : ?SingleFileSourceLocator {
-            if (! ($item->isFile() && pathinfo($item->getRealPath(), \PATHINFO_EXTENSION) === 'php')) {
                 return null;
             }
            return new SingleFileSourceLocator($item->getRealPath());
        },
        iterator_to_array($this->fileSystemIterator)
    ))));
}

通过以下方式:

代码语言:javascript
复制
private function getAggregatedSourceLocator() : AggregateSourceLocator
{
    return $this->aggregateSourceLocator ?: new AggregateSourceLocator(array_values(array_filter(array_map(
        function (\SplFileInfo $item) : ?SingleFileSourceLocator {
+            $flag = in_array(pathinfo($item->getRealPath(), \PATHINFO_EXTENSION), ['php', 'class']);
+            if (! ($item->isFile() && $flag)) {
                 return null;
             }
            return new SingleFileSourceLocator($item->getRealPath());
        },
        iterator_to_array($this->fileSystemIterator)
    ))));
}

工作到提交47b76f7,版本

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45358332

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档