-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Disable backslash escaping in "is allowed" helper #169
Conversation
Thanks. can you explain the bug you're seeing? Does this change fix it? Because I have a test that compares Windows paths phpstan-disallowed-calls/tests/IsAllowedFileHelperTest.php Lines 84 to 88 in cc97bfb
The matches() method calls absolutizePath() which calls normalizePath() which normalizes paths:https://github.com/phpstan/phpstan-src/blob/e5c1a594aa87df3a174afed58a1ef5a6cefe8d49/src/File/FileHelper.php#L77 |
Sure! Yes, the change does fix the issue. My config is something like this: disallowedFunctionCalls:
-
function: 'foo()'
message: 'use bar() instead'
allowIn:
- app/Models/Foo.php When I run phpstan for
Adding
|
As for the tests, they also seem a bit problematic on Windows (this is on PHP 8.1.3):
Log: https://gist.github.com/mnastalski/aebfe41bbfb6ae56ccdadb781c5d0ee0 If I add the flag the amount of errors is much lower:
As you can see the Windows paths test you mentioned also fails. The first assertion (based on yield [
'\\src\\foo\\bar\\',
__DIR__ . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR . 'bar',
'/foo/bar/src/foo/bar',
]; I played around with the second assertion (based on |
I see, thanks for the PR! I'll try to get tests working on Windows too, sorry it's not working now 😊 |
I have released 2.11.6 with this PR. I have started testing on Windows too so you should be fine running it on Windows too, let me know. Thanks again, not just for this PR but for bringing the whole Windows problem to my attention. |
Yup, everything passes now! Thanks! |
allowIn
will fail to match files on Windows without theFNM_NOESCAPE
flag