Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Ben Selby authored
4 Changelog.md
Source Rendered
... ... @@ -1,6 +1,10 @@
1 1 Sublime PHP CodeSniffer, Linter and Mess Detector Plugin Changelog
2 2 ==================================================================
3 3
  4 +4.6.1
  5 +-----
  6 +* 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)
  7 +
4 8 4.6
5 9 ---
6 10 * 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)
2  README.md
Source Rendered
@@ -84,6 +84,7 @@ You can configure:
84 84 * phpcs_show_errors_in_status - Do you want the errors to be displayed in status bar when clicking on the line with error?
85 85 * phpcs_show_quick_panel - Do you want the errors to be displayed in the quick panel?
86 86 * phpcs_php_prefix_path - Needed on windows for phar based applications. Also if you cannot make phar executable. Avoid if possible
  87 +* phpcs_commands_to_php_prefix - List of commands you want the php path to prefix
87 88
88 89
89 90 **PHP_CodeSniffer**
@@ -126,4 +127,3 @@ OSError: [Error 2] No such file or directory
126 127
127 128 * Well, first of all you need to check that you have PHP_CodeSniffer, and if being used, the phpmd application.
128 129 * 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
129   -
17 phpcs.py
@@ -22,6 +22,7 @@ def load():
22 22 Pref.phpcs_show_errors_in_status = bool(settings.get('phpcs_show_errors_in_status'))
23 23 Pref.phpcs_show_quick_panel = bool(settings.get('phpcs_show_quick_panel'))
24 24 Pref.phpcs_php_prefix_path = settings.get('phpcs_php_prefix_path', '')
  25 + Pref.phpcs_commands_to_php_prefix = settings.get('phpcs_commands_to_php_prefix', [])
25 26
26 27 Pref.phpcs_sniffer_run = bool(settings.get('phpcs_sniffer_run'))
27 28 Pref.phpcs_command_on_save = bool(settings.get('phpcs_command_on_save'))
@@ -105,10 +106,18 @@ def execute(self, path):
105 106 if Pref.phpcs_sniffer_run != True:
106 107 return
107 108
  109 + if Pref.phpcs_php_prefix_path != "" and self.__class__.__name__ in Pref.phpcs_commands_to_php_prefix:
  110 + args = [Pref.phpcs_php_prefix_path]
  111 +
108 112 if Pref.phpcs_executable_path != "":
109   - args = [Pref.phpcs_executable_path]
  113 + application_path = Pref.phpcs_executable_path
110 114 else:
111   - args = ['phpcs']
  115 + application_path = 'phpcs'
  116 +
  117 + if (len(args) > 0):
  118 + args.append(application_path)
  119 + else:
  120 + args = [application_path]
112 121
113 122 args.append("--report=checkstyle")
114 123
@@ -138,7 +147,7 @@ def execute(self, path):
138 147
139 148 args = []
140 149
141   - if Pref.phpcs_php_prefix_path != "":
  150 + if Pref.phpcs_php_prefix_path != "" and self.__class__.__name__ in Pref.phpcs_commands_to_php_prefix:
142 151 args = [Pref.phpcs_php_prefix_path]
143 152
144 153 if Pref.php_cs_fixer_executable_path != "":
@@ -181,7 +190,7 @@ def execute(self, path):
181 190
182 191 args = []
183 192
184   - if Pref.phpcs_php_prefix_path != "":
  193 + if Pref.phpcs_php_prefix_path != "" and self.__class__.__name__ in Pref.phpcs_commands_to_php_prefix:
185 194 args = [Pref.phpcs_php_prefix_path]
186 195
187 196 if Pref.phpmd_executable_path != "":
10 phpcs.sublime-settings
@@ -31,6 +31,16 @@
31 31 // executable. Avoid setting this if at all possible
32 32 "phpcs_php_prefix_path": "",
33 33
  34 + // Options include:
  35 + // - Sniffer
  36 + // - Fixer
  37 + // - Mess Detector
  38 + //
  39 + // This will prepend the application with the path to php
  40 + // Needed for windows, or anyone who doesn't/can't make phars
  41 + // executable. Avoid setting this if at all possible
  42 + "phpcs_commands_to_php_prefix": [],
  43 +
34 44
35 45
36 46 // PHP_CodeSniffer settings

0 comments on commit aff55a2

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