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)
1520
1520
/*
1521
1521
* For php, we know the executable path. There's no need to look it up.
1522
1522
*/
1523
+
1523
1524
return PHP_BINARY ;
1524
1525
}
1525
1526
Original file line number Diff line number Diff line change 17
17
class SyntaxSniff implements Sniff
18
18
{
19
19
20
+ /**
21
+ * The path to the PHP version we are checking with.
22
+ *
23
+ * @var string
24
+ */
25
+ private $ phpPath = null ;
26
+
20
27
21
28
/**
22
29
* Returns an array of tokens this test wants to listen for.
@@ -41,8 +48,12 @@ public function register()
41
48
*/
42
49
public function process (File $ phpcsFile , $ stackPtr )
43
50
{
51
+ if ($ this ->phpPath === null ) {
52
+ $ this ->phpPath = Config::getExecutablePath ('php ' );
53
+ }
54
+
44
55
$ 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 " ;
46
57
$ output = shell_exec ($ cmd );
47
58
$ matches = [];
48
59
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