File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Standards/Generic/Sniffs/PHP Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1520,6 +1520,7 @@ public static function getExecutablePath($name)
15201520 /*
15211521 * For php, we know the executable path. There's no need to look it up.
15221522 */
1523+
15231524 return PHP_BINARY ;
15241525 }
15251526
Original file line number Diff line number Diff line change 1717class SyntaxSniff implements Sniff
1818{
1919
20+ /**
21+ * The path to the PHP version we are checking with.
22+ *
23+ * @var string
24+ */
25+ private $ phpPath = null ;
26+
2027
2128 /**
2229 * Returns an array of tokens this test wants to listen for.
@@ -41,8 +48,12 @@ public function register()
4148 */
4249 public function process (File $ phpcsFile , $ stackPtr )
4350 {
51+ if ($ this ->phpPath === null ) {
52+ $ this ->phpPath = Config::getExecutablePath ('php ' );
53+ }
54+
4455 $ fileName = escapeshellarg ($ phpcsFile ->getFilename ());
45- $ cmd = escapeshellcmd (Config:: getExecutablePath ( ' php ' ) )." -l -d display_errors=1 -d error_prepend_string='' $ fileName 2>&1 " ;
56+ $ cmd = escapeshellcmd ($ this -> phpPath )." -l -d display_errors=1 -d error_prepend_string='' $ fileName 2>&1 " ;
4657 $ output = shell_exec ($ cmd );
4758 $ matches = [];
4859 if (preg_match ('/^.*error:(.*) in .* on line ([0-9]+)/m ' , trim ($ output ), $ matches ) === 1 ) {
You can’t perform that action at this time.
0 commit comments