【问题标题】:Does ApiGen 5 support multiple file extensions?ApiGen 5 是否支持多个文件扩展名?
【发布时间】:2017-07-31 06:40:28
【问题描述】:

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

我的问题是双重的:首先,是否有可能让 ApiGen 识别.class 文件,其次,如果可能的话,如何去做?

【问题讨论】:

    标签: php apigen


    【解决方案1】:

    我找到了一种方法……但它很老套。我在这里发布它是希望它可以帮助其他人。

    解决方案实际上不在 ApiGen 中,而是在 roave/better-reflection 中。具体来说,在文件src/SourceLocator/Type/FileIteratorSourceLocator.php 中,在方法@​​987654323@ 中,在匿名函数中。

    替换:

    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)
        ))));
    }
    

    与:

    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 开始工作,版本 something

    【讨论】:

      猜你喜欢
      • 2018-01-21
      • 1970-01-01
      • 1970-01-01
      • 2016-02-18
      • 1970-01-01
      • 2018-10-08
      • 1970-01-01
      • 2014-01-18
      • 1970-01-01
      相关资源
      最近更新 更多