1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
--TEST--
multiple files syntax check
--SKIPIF--
<?php include "skipif.inc"; ?>
--INI--
display_errors=stdout
--FILE--
<?php
include "include.inc";
function run_and_output($cmd) {
if (!defined("PHP_WINDOWS_VERSION_MAJOR")) {
$cmd .= " 2>/dev/null";
}
exec($cmd, $output, $exit_code);
print_r($output);
// Normalize Windows vs Linux exit codes. On Windows exit code -1 is actually -1 instead of 255.
if ($exit_code < 0) {
$exit_code += 256;
}
var_dump($exit_code);
}
$php = get_cgi_path();
reset_env_vars();
$filename_good = __DIR__."/012_good.test.php";
$filename_good_escaped = escapeshellarg($filename_good);
$filename_bad = __DIR__."/012_bad.test.php";
$filename_bad_escaped = escapeshellarg($filename_bad);
$code = '
<?php
echo "hi";
';
file_put_contents($filename_good, $code);
$code = '
<?php
class test
private $var;
}
?>
';
file_put_contents($filename_bad, $code);
run_and_output("$php -n -l $filename_good_escaped $filename_good_escaped");
run_and_output("$php -n -l $filename_good_escaped some.unknown $filename_good_escaped");
run_and_output("$php -n -l $filename_good_escaped $filename_bad_escaped $filename_good_escaped");
run_and_output("$php -n -l $filename_bad_escaped $filename_bad_escaped");
run_and_output("$php -n -l $filename_bad_escaped some.unknown $filename_bad_escaped");
run_and_output("$php -n -l $filename_bad_escaped $filename_bad_escaped some.unknown");
echo "Done\n";
?>
--CLEAN--
<?php
@unlink($filename_good);
@unlink($filename_bad);
?>
--EXPECTF--
Array
(
[0] => No syntax errors detected in %s012_good.test.php
[1] => No syntax errors detected in %s012_good.test.php
)
int(0)
Array
(
[0] => No syntax errors detected in %s012_good.test.php
[1] => No input file specified.
)
int(255)
Array
(
[0] => No syntax errors detected in %s012_good.test.php
[1] => <br />
[2] => <b>Parse error</b>: syntax error, unexpected token "private", expecting "{" in <b>%s012_bad.test.php</b> on line <b>5</b><br />
[3] => Errors parsing %s012_bad.test.php
[4] => No syntax errors detected in %s012_good.test.php
)
int(255)
Array
(
[0] => <br />
[1] => <b>Parse error</b>: syntax error, unexpected token "private", expecting "{" in <b>%s012_bad.test.php</b> on line <b>5</b><br />
[2] => Errors parsing %s012_bad.test.php
[3] => <br />
[4] => <b>Parse error</b>: syntax error, unexpected token "private", expecting "{" in <b>%s012_bad.test.php</b> on line <b>5</b><br />
[5] => Errors parsing %s012_bad.test.php
)
int(255)
Array
(
[0] => <br />
[1] => <b>Parse error</b>: syntax error, unexpected token "private", expecting "{" in <b>%s012_bad.test.php</b> on line <b>5</b><br />
[2] => Errors parsing %s012_bad.test.php
[3] => No input file specified.
)
int(255)
Array
(
[0] => <br />
[1] => <b>Parse error</b>: syntax error, unexpected token "private", expecting "{" in <b>%s012_bad.test.php</b> on line <b>5</b><br />
[2] => Errors parsing %s012_bad.test.php
[3] => <br />
[4] => <b>Parse error</b>: syntax error, unexpected token "private", expecting "{" in <b>%s012_bad.test.php</b> on line <b>5</b><br />
[5] => Errors parsing %s012_bad.test.php
[6] => No input file specified.
)
int(255)
Done
|