summaryrefslogtreecommitdiff
path: root/sapi/phpdbg
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-02-03 13:41:45 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-02-03 13:42:08 +0100
commit169805777c17892865ae462ae0a0895344a7fd3c (patch)
tree715ab54d18d387e0f2fec607a97462af525f2556 /sapi/phpdbg
parent6b38251820be4ab2eb38c55d41c6680d0bff83f3 (diff)
parent58b17906f512866c2e34844fa497ecdf7f1e1e3d (diff)
downloadphp-git-169805777c17892865ae462ae0a0895344a7fd3c.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Apply tidy formatting
Diffstat (limited to 'sapi/phpdbg')
-rwxr-xr-xsapi/phpdbg/create-test.php136
-rw-r--r--sapi/phpdbg/phpdbg_bp.c12
-rw-r--r--sapi/phpdbg/test.php68
3 files changed, 108 insertions, 108 deletions
diff --git a/sapi/phpdbg/create-test.php b/sapi/phpdbg/create-test.php
index 3cba7d42b0..06fb7e1632 100755
--- a/sapi/phpdbg/create-test.php
+++ b/sapi/phpdbg/create-test.php
@@ -30,37 +30,37 @@ $file = "";
$cmdargv = "";
if (isset($argc) && $argc > 1) {
- $post_ddash = false;
- for ($i = 1; $i < $argc; $i++) {
- if ($argv[$i][0] == "-" && !$post_ddash) {
- switch (substr($argv[$i], 1)) {
- case "p":
- $phpdbg = $argv[++$i];
- break;
- case "n":
- $pass_options .= " -n";
- break;
- case "d":
- $pass_options .= " -d ".escapeshellarg($argv[++$i]);
- $ini[] = $argv[$i];
- break;
- case "-":
- $post_ddash = true;
- break;
- }
- } else {
- $real_argv[] = $argv[$i];
- }
- }
- if (isset($real_argv[0])) {
- $file = realpath($real_argv[0]);
- $cmdargv = implode(" ", array_map("escapeshellarg", array_slice($real_argv, 1)));
- }
+ $post_ddash = false;
+ for ($i = 1; $i < $argc; $i++) {
+ if ($argv[$i][0] == "-" && !$post_ddash) {
+ switch (substr($argv[$i], 1)) {
+ case "p":
+ $phpdbg = $argv[++$i];
+ break;
+ case "n":
+ $pass_options .= " -n";
+ break;
+ case "d":
+ $pass_options .= " -d ".escapeshellarg($argv[++$i]);
+ $ini[] = $argv[$i];
+ break;
+ case "-":
+ $post_ddash = true;
+ break;
+ }
+ } else {
+ $real_argv[] = $argv[$i];
+ }
+ }
+ if (isset($real_argv[0])) {
+ $file = realpath($real_argv[0]);
+ $cmdargv = implode(" ", array_map("escapeshellarg", array_slice($real_argv, 1)));
+ }
}
$proc = proc_open("$phpdbg $pass_options $file -- $cmdargv", [["pipe", "r"], ["pipe", "w"], ["pipe", "w"]], $pipes);
if (!$proc) {
- die("Couldn't start phpdbg\n");
+ die("Couldn't start phpdbg\n");
}
$input = $output = "";
@@ -68,47 +68,47 @@ $input = $output = "";
stream_set_blocking(STDIN, false);
do {
- $r = [$pipes[1], STDIN];
- $w = $e = null;
- $n = @stream_select($r, $w, $e, null);
-
- if ($n > 0) {
- if ("" != $in = fread(STDIN, 1024)) {
- $input .= $in;
- fwrite($pipes[0], $in);
- continue;
- }
-
- if (feof(STDIN)) {
- die("stdin closed?!\n");
- }
-
- if (feof($pipes[1])) {
- $n = false;
- } else {
- $output .= $c = fgetc($pipes[1]);
- echo $c;
- }
- }
+ $r = [$pipes[1], STDIN];
+ $w = $e = null;
+ $n = @stream_select($r, $w, $e, null);
+
+ if ($n > 0) {
+ if ("" != $in = fread(STDIN, 1024)) {
+ $input .= $in;
+ fwrite($pipes[0], $in);
+ continue;
+ }
+
+ if (feof(STDIN)) {
+ die("stdin closed?!\n");
+ }
+
+ if (feof($pipes[1])) {
+ $n = false;
+ } else {
+ $output .= $c = fgetc($pipes[1]);
+ echo $c;
+ }
+ }
} while ($n !== false);
stream_set_blocking(STDIN, true);
print "\n";
if (!isset($name)) {
- print "Specify the test description: ";
- $desc = trim(fgets(STDIN));
+ print "Specify the test description: ";
+ $desc = trim(fgets(STDIN));
}
while (!isset($testfile)) {
- print "Specify the test file name (leave empty to write to stderr): ";
- $testfile = trim(fgets(STDIN));
- if ($testfile != "" && file_exists($testfile)) {
- print "That file already exists. Type y or yes to overwrite: ";
- $y = trim(fgets(STDIN));
- if ($y !== "y" && $y !== "yes") {
- unset($testfile);
- }
- }
+ print "Specify the test file name (leave empty to write to stderr): ";
+ $testfile = trim(fgets(STDIN));
+ if ($testfile != "" && file_exists($testfile)) {
+ print "That file already exists. Type y or yes to overwrite: ";
+ $y = trim(fgets(STDIN));
+ if ($y !== "y" && $y !== "yes") {
+ unset($testfile);
+ }
+ }
}
$output = str_replace("string(".strlen($file).") \"$file\"", 'string(%d) "%s"', $output);
@@ -125,24 +125,24 @@ $output
TEST;
if (!empty($ini)) {
- $testdata .= "\n--INI--\n".implode("\n", $ini);
+ $testdata .= "\n--INI--\n".implode("\n", $ini);
}
if ($cmdargv != "") {
- $testdata .= "\n--ARGS--\n$cmdargv";
+ $testdata .= "\n--ARGS--\n$cmdargv";
}
if ($file != "") {
- $testdata .= "\n--FILE--\n".file_get_contents($file);
+ $testdata .= "\n--FILE--\n".file_get_contents($file);
}
if ($testfile == "") {
- print "\n";
+ print "\n";
} elseif (file_put_contents($testfile, $testdata)) {
- print "Test saved to $testfile\n";
+ print "Test saved to $testfile\n";
} else {
- print "The test could not be saved to $testfile; outputting on stderr now\n";
- $testfile = "";
+ print "The test could not be saved to $testfile; outputting on stderr now\n";
+ $testfile = "";
}
if ($testfile == "") {
- fwrite(STDERR, $testdata);
+ fwrite(STDERR, $testdata);
}
diff --git a/sapi/phpdbg/phpdbg_bp.c b/sapi/phpdbg/phpdbg_bp.c
index f3c453f7d3..e6b7c10225 100644
--- a/sapi/phpdbg/phpdbg_bp.c
+++ b/sapi/phpdbg/phpdbg_bp.c
@@ -196,19 +196,19 @@ PHPDBG_API void phpdbg_export_breakpoints_to_string(char **str) /* {{{ */
"%sbreak at %s#%ld if %s\n",
*str, conditional->param.str, conditional->param.num, conditional->code);
break;
-
+
case NUMERIC_METHOD_PARAM:
phpdbg_asprintf(&new_str,
"%sbreak at %s::%s#%ld if %s\n",
*str, conditional->param.method.class, conditional->param.method.name, conditional->param.num, conditional->code);
break;
-
+
case ADDR_PARAM:
phpdbg_asprintf(&new_str,
"%sbreak at 0X%lx if %s\n",
*str, conditional->param.addr, conditional->code);
break;
-
+
case STR_PARAM:
phpdbg_asprintf(&new_str,
"%sbreak at %s if %s\n", *str, conditional->param.str, conditional->code);
@@ -839,7 +839,7 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co
case ADDR_PARAM:
/* do nothing */
break;
-
+
default:
phpdbg_error("eval", "type=\"invalidparameter\"", "Invalid parameter type for conditional breakpoint");
return;
@@ -855,10 +855,10 @@ static inline void phpdbg_create_conditional_break(phpdbg_breakcond_t *brake, co
if (new_break.param.type == FILE_PARAM ||
new_break.param.type == NUMERIC_FILE_PARAM) {
char realpath[MAXPATHLEN];
-
+
if (VCWD_REALPATH(new_break.param.file.name, realpath)) {
efree(new_break.param.file.name);
-
+
new_break.param.file.name = estrdup(realpath);
} else {
phpdbg_error("eval", "type=\"invalidparameter\"", "Invalid file for conditional break %s", new_break.param.file.name);
diff --git a/sapi/phpdbg/test.php b/sapi/phpdbg/test.php
index d93c81a89a..265ea9697c 100644
--- a/sapi/phpdbg/test.php
+++ b/sapi/phpdbg/test.php
@@ -1,35 +1,35 @@
<?php
if (isset($include)) {
- include (sprintf("%s/web-bootstrap.php", dirname(__FILE__)));
+ include (sprintf("%s/web-bootstrap.php", dirname(__FILE__)));
}
$stdout = fopen("php://stdout", "w+");
class phpdbg {
- private $sprintf = "%s: %s\n";
+ private $sprintf = "%s: %s\n";
- public function isGreat($greeting = null) {
- printf($this->sprintf, __METHOD__, $greeting);
- return $this;
- }
+ public function isGreat($greeting = null) {
+ printf($this->sprintf, __METHOD__, $greeting);
+ return $this;
+ }
}
function mine() {
- var_dump(func_get_args());
+ var_dump(func_get_args());
}
function test($x, $y = 0) {
- $var = $x + 1;
- $var += 2;
- $var <<= 3;
+ $var = $x + 1;
+ $var += 2;
+ $var <<= 3;
- $foo = function () {
- echo "bar!\n";
- };
+ $foo = function () {
+ echo "bar!\n";
+ };
- $foo();
+ $foo();
- yield $var;
+ yield $var;
}
$dbg = new phpdbg();
@@ -38,43 +38,43 @@ var_dump(
$dbg->isGreat("PHP Rocks!!"));
foreach (test(1,2) as $gen)
- continue;
+ continue;
echo "it works!\n";
if (isset($dump))
- var_dump($_SERVER);
+ var_dump($_SERVER);
function phpdbg_test_ob()
{
- echo 'Start';
- ob_start();
- echo 'Hello';
- $b = ob_get_clean();
- echo 'End';
- echo $b;
+ echo 'Start';
+ ob_start();
+ echo 'Hello';
+ $b = ob_get_clean();
+ echo 'End';
+ echo $b;
}
$array = [
- 1,
- 2,
- [3, 4],
- [5, 6],
+ 1,
+ 2,
+ [3, 4],
+ [5, 6],
];
$array[] = 7;
array_walk($array, function (&$item) {
- if (is_array($item))
- $item[0] += 2;
- else
- $item -= 1;
+ if (is_array($item))
+ $item[0] += 2;
+ else
+ $item -= 1;
});
class testClass {
- public $a = 2;
- protected $b = [1, 3];
- private $c = 7;
+ public $a = 2;
+ protected $b = [1, 3];
+ private $c = 7;
}
$obj = new testClass;