-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not absolutize path when path starts with wildcard #64
Conversation
Thanks. Interesting, PHPStan indeed does have an exception for wildcards added in phpstan/phpstan-src@beaf375 so I guess it makes sense to do what PHPStan does. |
Great that you found where this is done, I searched the codebase but couldn't find it. :) |
31851cd
to
1b90165
Compare
@spaze Applied feedback ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small detail and hopefully the last one.
I'm using `allowIn` a lot to exclude certain directories from being disallowed. I noticed that this library absolutizes all inputs making them relative to the current working directory. That means that if i write: ```neon allowIn: - tests ``` it becomes `/my/working/directory/tests`. And it also means that if I write ```neon allowIn: - **/tests ``` it becomes `/my/working/directory/**/tests`. I think it should not be done when the path starts with a wildcard. PHPStorm has integration for PHPStan and I noticed that all my allowed paths were ignored by PHPStan when running in PHPStorm. Turns out, PHPStorm doesn't run PHPStan on the actual file, but instead copies the file to a temporary directory and then performs analysis on it. So when you have `tests/MyTest.php` it will copy it to `/private/var/folders/m4/2_8czq_s1dbcfkm1yf8zjgg80000gn/T/PHPStantemp_folder7840/tests/MyTest.php` and then run it. Because this library makes the allowed paths absolute to the working directory, the allowed path will never match that with the path from the temporary directory. Current work around that I have is to use the following config: ```neon allowIn: - tests/* - /private/var/**/PHPStantemp_folder*/tests/* ``` But by applying this change, I can write it like this: ```neon allowIn: - **/tests/* ``` I checked how PHPStan deals with this. It does not absolutize paths when doing things like this: ```neon parameters: ignoreErrors: - message: '#Dynamic call to static method PHPUnit\\.*#' paths: - **/tests/* ``` That means that the above example works fine, also in PHPStorm. I also reported this to PHPStorm but I'm not sure if this will be fixed. See https://youtrack.jetbrains.com/issue/WI-58890.
Thanks, just released as v1.4.0. |
I'm using
allowIn
a lot to exclude certain directories from being disallowed.I noticed that this library absolutizes all inputs making them relative to the current working directory.
That means that if i write:
it becomes
/my/working/directory/tests
. And it also means that if I writeit becomes
/my/working/directory/**/tests
.I think it should not be done when the path starts with a wildcard.
PHPStorm has integration for PHPStan and I noticed that all my allowed paths were ignored by PHPStan when running in PHPStorm. Turns out, PHPStorm doesn't run PHPStan on the actual file, but instead copies the file to a temporary directory and then performs analysis on it.
So when you have
tests/MyTest.php
it will copy it to/private/var/folders/m4/2_8czq_s1dbcfkm1yf8zjgg80000gn/T/PHPStantemp_folder7840/tests/MyTest.php
and then run it.Because this library makes the allowed paths absolute to the working directory, the allowed path will never match that with the path from the temporary directory.
Current work around that I have is to use the following config:
But by applying this change, I can write it like this:
I checked how PHPStan deals with this. It does not absolutize paths when doing things like this:
That means that the above example works fine, also in PHPStorm.
I also reported this to PHPStorm but I'm not sure if this will be fixed.
See https://youtrack.jetbrains.com/issue/WI-58890.