Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Provide configuration option "phpcs_commands_to_php_prefix"

This allows you to distinguish which commands should have the php path prefixed.

Related to GH-49
  • Loading branch information...
commit aff55a291c82d9ea63f770341f338ff67d15fa3c 1 parent dd8e600
@benmatselby authored
Showing with 28 additions and 5 deletions.
  1. +4 −0 Changelog.md
  2. +1 −1  README.md
  3. +13 −4 phpcs.py
  4. +10 −0 phpcs.sublime-settings
View
4 Changelog.md
@@ -1,6 +1,10 @@
Sublime PHP CodeSniffer, Linter and Mess Detector Plugin Changelog
==================================================================
+4.6.1
+-----
+* Provided configuration option "phpcs_commands_to_php_prefix" that allows you to distinguish which commands should have the php path prefixed. Thanks to [Hamrani ahmed](https://github.com/ahamrani) for raising [GH-49](https://github.com/benmatselby/sublime-phpcs/issues/49)
+
4.6
---
* Fixes for windows based users and the use of phar files. Thanks to [Hamrani ahmed](https://github.com/ahamrani) for raising [GH-47](https://github.com/benmatselby/sublime-phpcs/issues/47)
View
2  README.md
@@ -84,6 +84,7 @@ You can configure:
* phpcs_show_errors_in_status - Do you want the errors to be displayed in status bar when clicking on the line with error?
* phpcs_show_quick_panel - Do you want the errors to be displayed in the quick panel?
* phpcs_php_prefix_path - Needed on windows for phar based applications. Also if you cannot make phar executable. Avoid if possible
+* phpcs_commands_to_php_prefix - List of commands you want the php path to prefix
**PHP_CodeSniffer**
@@ -126,4 +127,3 @@ OSError: [Error 2] No such file or directory
* Well, first of all you need to check that you have PHP_CodeSniffer, and if being used, the phpmd application.
* If you have these applications installed, then it sounds like those applications are not in your PATH, or cannot be found in your PATH by the Python runtime, so configure "phpcs_php_path", "phpcs_executable_path", "phpmd_executable_path" and "php_cs_fixer_executable_path" with the actual paths to those applications
-
View
17 phpcs.py
@@ -22,6 +22,7 @@ def load():
Pref.phpcs_show_errors_in_status = bool(settings.get('phpcs_show_errors_in_status'))
Pref.phpcs_show_quick_panel = bool(settings.get('phpcs_show_quick_panel'))
Pref.phpcs_php_prefix_path = settings.get('phpcs_php_prefix_path', '')
+ Pref.phpcs_commands_to_php_prefix = settings.get('phpcs_commands_to_php_prefix', [])
Pref.phpcs_sniffer_run = bool(settings.get('phpcs_sniffer_run'))
Pref.phpcs_command_on_save = bool(settings.get('phpcs_command_on_save'))
@@ -105,10 +106,18 @@ def execute(self, path):
if Pref.phpcs_sniffer_run != True:
return
+ if Pref.phpcs_php_prefix_path != "" and self.__class__.__name__ in Pref.phpcs_commands_to_php_prefix:
+ args = [Pref.phpcs_php_prefix_path]
+
if Pref.phpcs_executable_path != "":
- args = [Pref.phpcs_executable_path]
+ application_path = Pref.phpcs_executable_path
else:
- args = ['phpcs']
+ application_path = 'phpcs'
+
+ if (len(args) > 0):
+ args.append(application_path)
+ else:
+ args = [application_path]
args.append("--report=checkstyle")
@@ -138,7 +147,7 @@ def execute(self, path):
args = []
- if Pref.phpcs_php_prefix_path != "":
+ if Pref.phpcs_php_prefix_path != "" and self.__class__.__name__ in Pref.phpcs_commands_to_php_prefix:
args = [Pref.phpcs_php_prefix_path]
if Pref.php_cs_fixer_executable_path != "":
@@ -181,7 +190,7 @@ def execute(self, path):
args = []
- if Pref.phpcs_php_prefix_path != "":
+ if Pref.phpcs_php_prefix_path != "" and self.__class__.__name__ in Pref.phpcs_commands_to_php_prefix:
args = [Pref.phpcs_php_prefix_path]
if Pref.phpmd_executable_path != "":
View
10 phpcs.sublime-settings
@@ -31,6 +31,16 @@
// executable. Avoid setting this if at all possible
"phpcs_php_prefix_path": "",
+ // Options include:
+ // - Sniffer
+ // - Fixer
+ // - Mess Detector
+ //
+ // This will prepend the application with the path to php
+ // Needed for windows, or anyone who doesn't/can't make phars
+ // executable. Avoid setting this if at all possible
+ "phpcs_commands_to_php_prefix": [],
+
// PHP_CodeSniffer settings

0 comments on commit aff55a2

Please sign in to comment.
Something went wrong with that request. Please try again.