1
我正在使用ApiGen 5.0.0-RC3,我無法弄清楚如何讓它搜索.class
文件和.inc
文件以及.php
文件。ApiGen 5是否支持多個文件擴展名?
我的問題是雙重的:首先,是否有可能讓ApiGen識別.class
文件,其次,如果可能的話,會怎麼做呢?
我正在使用ApiGen 5.0.0-RC3,我無法弄清楚如何讓它搜索.class
文件和.inc
文件以及.php
文件。ApiGen 5是否支持多個文件擴展名?
我的問題是雙重的:首先,是否有可能讓ApiGen識別.class
文件,其次,如果可能的話,會怎麼做呢?
我找到了一種方法...但它很hacky。我在這裏發佈它希望能夠幫助別人。
該解決方案實際上並不在ApiGen中,而是在roave/better-reflection中。具體來說,在文件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,版本東西