ObliviousHarmony / vscode-php-codesniffer

A VS Code extension for integrating PHP_CodeSniffer.
https://marketplace.visualstudio.com/items?itemName=obliviousharmony.vscode-php-codesniffer
Other
38 stars 2 forks source link

Added `Automatic` Standard Option #61

Closed ObliviousHarmony closed 1 year ago

ObliviousHarmony commented 1 year ago

All Submissions:

Changes proposed in this Pull Request:

This pull request adds a new Automatic option for phpCodeSniffer.standard. When this new option is used the extension will attempt to find one of the configuration file types that we've defined. It will traverse from the document's directory to the workspace root seeking out an appropriate file.

As part of this work I also went ahead and refactored the way that the standard works a little bit. There's no longer a need to check for type strings and I've removed the StandardType enum entirely.

Closes #59.

How to test the changes in this Pull Request:

  1. Set phpCodeSniffer.standard to Automatic in the settings.
  2. Create a workspace that has both a root phpcs.xml file and a phpcs.xml file in a nested directory.
  3. Create a PHP file in the nested directory and make sure it violates the nested coding standard but not the one at the root.
  4. Delete the nested coding standard and the errors should go away.
  5. Rename the root file to .phpcs.xml and verify that it still works.
ObliviousHarmony commented 1 year ago

Hey @leonardola,

What do you think of this solution? If it's not too much trouble, could you try this PR out with your workspace and see if it works like you'd expect it to?