File tree Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,20 @@ public function testLine($line) {
113
113
return $ issues ;
114
114
}
115
115
116
+ /**
117
+ * Return the PHP binary location.
118
+ *
119
+ * @access public
120
+ * @return string PHP binary location.
121
+ */
122
+ public function getPHPBinaryPath () {
123
+ $ binary = 'php ' ;
124
+ if ($ this ->php !== null ) {
125
+ $ binary = $ this ->php ;
126
+ }
127
+ return $ binary ;
128
+ }
129
+
116
130
/**
117
131
* Set the location of the PHP binary.
118
132
*
@@ -124,6 +138,21 @@ public function setPHPBinaryPath($path) {
124
138
$ this ->php = $ path ;
125
139
}
126
140
141
+ /**
142
+ * Return the version of PHP for the selected binary.
143
+ *
144
+ * @access public
145
+ * @return mixed Version string or false on error.
146
+ */
147
+ public function getPHPVersion () {
148
+ $ binary = $ this ->getPHPBinaryPath ();
149
+ $ version = exec ($ binary .' -r "echo(phpversion());" 2>&1 ' , $ version );
150
+
151
+ $ version = trim ($ version );
152
+
153
+ return version_compare ($ version , "7.0.0-dev " , ">= " );
154
+ }
155
+
127
156
/**
128
157
* Check if syntax is valid and return line information if not.
129
158
*
@@ -132,10 +161,7 @@ public function setPHPBinaryPath($path) {
132
161
* @return array Test Results
133
162
*/
134
163
public function checkSyntax ($ filePath ) {
135
- $ binary = 'php ' ;
136
- if ($ this ->php !== null ) {
137
- $ binary = $ this ->php ;
138
- }
164
+ $ binary = $ this ->getPHPBinaryPath ();
139
165
exec ($ binary .' -l ' .$ filePath .' 2>&1 ' , $ output );
140
166
141
167
$ syntax = [];
Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ private function run() {
106
106
$ filePath = $ this ->scanner ->getCurrentFilePath ();
107
107
if (!$ this ->options ->getOption ('t ' ) || in_array ('syntax ' , $ this ->options ->getOption ('t ' ), true )) {
108
108
$ checkSyntax = true ;
109
+ $ versionGood = $ this ->tests ->getPHPVersion ();
110
+ if (!$ versionGood ) {
111
+ $ this ->reporter ->add ("ERROR! Syntax checking was selected and a PHP binary lower than 7.0.0-dev was specified. " , 0 , 1 );
112
+ }
109
113
} else {
110
114
$ checkSyntax = false ;
111
115
}
You can’t perform that action at this time.
0 commit comments