You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If Phan runs into a symlink loop when trying to find files, it will print a warning, not find all of the files that should be processed, and then may exit with a successful exit code.
Reproduction
Create an empty directory for the test.
composer require --dev phan/phan
Create a file with something Phan will complain about: printf '<?php\n\nfoo();' > foo.php
Create the directory with a symlink loop. For some reason I find I have to create two symlinks for it to reproduce the bug. 🤷 mkdir subdir && ln -s . subdir/loop1 && ln -s . subdir/loop2
For good measure, create another file with something Phan will complain about: printf '<?php\n\nxxx();' > xxx.php
Run Phan and examine its exit code: vendor/bin/phan --debug --directory . --exclude-directory-list vendor; echo $?
Actual results
Phan prints a warning, doesn't scan any of the files, and exits with a status of 0.
WARNING: Caught exception while listing files in '.': RecursiveDirectoryIterator::__construct(./subdir/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop2/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop2/loop2/loop2/loop2/loop2/loop2/loop2/loop2): Failed to open directory: Too many levels of symbolic links
Phan did not parse any files in the project "/tmp/test" - This may be an issue with the Phan config or CLI options.
0
In some of the real-life cases where I ran into this, Phan did process a subset of the files it was supposed to process, presumably whichever ones it found before running into the symlink loop.
Expected results
Either Phan detects the loop and still analyzes both PHP files, or it prints an error that it couldn't successfully process the provided directories and exits with a non-zero status.
To be clear, I'd be happy with it doing something like this:
ERROR: Caught exception while listing files in '.': RecursiveDirectoryIterator::__construct(./subdir/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop2/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop2/loop2/loop2/loop2/loop2/loop2/loop2/loop2): Failed to open directory: Too many levels of symbolic links
1
The non-zero exit code would make our CI that's running Phan indicate that an error occurred. Then I'd be notified to look into it, at which point I'd figure out what I needed to change in our config (probably an addition to exclude_file_list or exclude_file_regex) to avoid having Phan look into whichever path has the loop.
I'd also be happy with this:
WARNING: Caught exception while listing files in '.': RecursiveDirectoryIterator::__construct(./subdir/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop2/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop1/loop2/loop2/loop2/loop2/loop2/loop2/loop2/loop2): Failed to open directory: Too many levels of symbolic links
[... processing proceeds with all files that would have been found if it weren't for the loop ...]
Phan's analysis is complete
foo.php:3 PhanUndeclaredFunction Call to undeclared function \foo()
xxx.php:3 PhanUndeclaredFunction Call to undeclared function \xxx()
1
But making that happen would likely be more effort and I don't know that it would be worth it.
The text was updated successfully, but these errors were encountered:
If Phan runs into a symlink loop when trying to find files, it will print a warning, not find all of the files that should be processed, and then may exit with a successful exit code.
Reproduction
composer require --dev phan/phan
printf '<?php\n\nfoo();' > foo.php
mkdir subdir && ln -s . subdir/loop1 && ln -s . subdir/loop2
printf '<?php\n\nxxx();' > xxx.php
vendor/bin/phan --debug --directory . --exclude-directory-list vendor; echo $?
Actual results
Phan prints a warning, doesn't scan any of the files, and exits with a status of 0.
In some of the real-life cases where I ran into this, Phan did process a subset of the files it was supposed to process, presumably whichever ones it found before running into the symlink loop.
Expected results
Either Phan detects the loop and still analyzes both PHP files, or it prints an error that it couldn't successfully process the provided directories and exits with a non-zero status.
To be clear, I'd be happy with it doing something like this:
The non-zero exit code would make our CI that's running Phan indicate that an error occurred. Then I'd be notified to look into it, at which point I'd figure out what I needed to change in our config (probably an addition to
exclude_file_list
orexclude_file_regex
) to avoid having Phan look into whichever path has the loop.I'd also be happy with this:
But making that happen would likely be more effort and I don't know that it would be worth it.
The text was updated successfully, but these errors were encountered: