Conversation
I use symlinks in my projects to open the same file in multiple tabs in VSCode ( ref https://stackoverflow.com/a/73994770/1067003 for why i need to use symlinks), which causes Phan to crash like $ ./vendor/bin/phan ERROR: Unable to read file /home/hans/projects/easyad/classes/Controller/System/VitecBooking.2ln.php: SplFileInfo->isFile() is false for SplFileInfo->getType() == 'link' the easy fix is to just ignore links.
|
I have projects set up that rely on symlinks (e.g. where multiple applications depend on the same library as a symlinked folder) It'd be better to have this as a .phan/config.php setting such as |
|
@TysonAndre well my only problem was that phan crashed when encountering the link. i actually wouldn't mind if phan would follow the link instead of ignoring it. assuming nobody actually need links to be ignored, do you think we could just do a while ($file_info->isLink()) {
// follow links
$file_info = new SplFileInfo($file_info->getLinkTarget());
}? perhaps with a max-follow-link thing to protect against infinite link-to-link loop, which would cause the code above to hang - sounds like an extremely rare edge-case, but still, perhaps $link_counter=0;
while ($file_info->isLink()) {
// follow links
$file_info = new SplFileInfo($file_info->getLinkTarget());
if(++$link_counter >= 100) {
throw new \RuntimeException("infinite link loop");
}
}edit: the code above might be incorrect, seems one should use SplFileInfo::getRealPath instead of SplFileInfo::getLinkTarget |
I use symlinks in my projects to open the same file in multiple tabs in VSCode ( ref https://stackoverflow.com/a/73994770/1067003 for why i need to use symlinks),
which causes Phan to crash like
the easy fix is to just ignore links.