wongjn / vscode-php-sniffer

Visual Studio Code extension for PHP_Codesniffer validation and formatting.
https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer
MIT License
46 stars 7 forks source link

Fix: Compatibility with Windows Paths #73

Open miku3920 opened 11 months ago

miku3920 commented 11 months ago

This pull request addresses a compatibility issue with Windows paths in PHP_CodeSniffer. When the system uses backslashes (e.g., \\) as directory separators on Windows, it can lead to problems in pattern matching with preg_match.

To fix this issue, we have added a conditional check to ensure that Windows paths are consistently using forward slashes (e.g., /) as directory separators before adding them to the ignore patterns. This change ensures that paths are correctly matched and ignored, even on Windows systems.

This should resolve the "Compilation failed" warning related to preg_match that you've encountered.

Please review this pull request and let us know if it solves your problem. If you have any further comments or suggestions, feel free to share them. Thank you!

wongjn commented 11 months ago

Thank you for the contribution! A test covering this would be good, but I am aware that is not possible in CI and blocked by #71 at the moment.

miku3920 commented 11 months ago

Thank you for your prompt response and guidance. I'm eager to contribute a test for this fix. Could you please provide some insights on how to write the test and the necessary tools I should prepare for the task? Your advice would be greatly appreciated.