我使用的是ApiGen 5.0.0-RC3,我不知道如何让它搜索.class文件和.inc文件以及.php文件。
我的问题有两个:第一,是否有可能让ApiGen识别.class文件;第二,如果有可能,人们将如何处理?
发布于 2017-07-30 22:40:28
我找到了一个方法..。但还是挺烦人的。我把它放在这里是希望它能帮助其他人。
解决方案实际上不是在ApiGen中,而是在漫游/更好的反射中。具体来说,在文件src/SourceLocator/Type/FileIteratorSourceLocator.php中,在方法getAggregatedSourceLocator中,在匿名函数中。
取代:
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,版本
https://stackoverflow.com/questions/45358332
复制相似问题