diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-03 13:41:31 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-03 13:41:31 +0100 |
commit | 58b17906f512866c2e34844fa497ecdf7f1e1e3d (patch) | |
tree | fcfa56bc040ec99990610dba890b72ef4d560663 /sapi | |
parent | 4fd63185803aad42790c0ac38c144b346e283009 (diff) | |
download | php-git-58b17906f512866c2e34844fa497ecdf7f1e1e3d.tar.gz |
Apply tidy formatting
Mostly reindent PHP scripts to spaces.
Diffstat (limited to 'sapi')
-rwxr-xr-x | sapi/cli/generate_mime_type_map.php | 46 | ||||
-rw-r--r-- | sapi/cli/php_cli_server.c | 10 | ||||
-rwxr-xr-x | sapi/phpdbg/create-test.php | 136 | ||||
-rw-r--r-- | sapi/phpdbg/phpdbg_bp.c | 12 | ||||
-rw-r--r-- | sapi/phpdbg/test.php | 68 |
5 files changed, 136 insertions, 136 deletions
diff --git a/sapi/cli/generate_mime_type_map.php b/sapi/cli/generate_mime_type_map.php index b0176bb524..40f546ef83 100755 --- a/sapi/cli/generate_mime_type_map.php +++ b/sapi/cli/generate_mime_type_map.php @@ -8,36 +8,36 @@ $source = count($_SERVER['argv']) > 1 ? $_SERVER['argv'][1] : 'https://raw.githu // See if we can actually load it. $types = @file($source); if ($types === false) { - fprintf(STDERR, "Error: unable to read $source\n"); - exit(1); + fprintf(STDERR, "Error: unable to read $source\n"); + exit(1); } // Remove comments and flip into an extensions array. $extensions = []; array_walk($types, function ($line) use (&$extensions) { - $line = trim($line); - if ($line && $line[0] != '#') { - $fields = preg_split('/\s+/', $line); - if (count($fields) > 1) { - $mime = array_shift($fields); - foreach ($fields as $extension) { - $extensions[$extension] = $mime; - } - } - } + $line = trim($line); + if ($line && $line[0] != '#') { + $fields = preg_split('/\s+/', $line); + if (count($fields) > 1) { + $mime = array_shift($fields); + foreach ($fields as $extension) { + $extensions[$extension] = $mime; + } + } + } }); $additional_mime_maps = [ - "map" => "application/json", // from commit: a0d62f08ae8cbebc88e5c92e08fca8d0cdc7309d - "jsm" => "application/javascript", + "map" => "application/json", // from commit: a0d62f08ae8cbebc88e5c92e08fca8d0cdc7309d + "jsm" => "application/javascript", ]; foreach($additional_mime_maps as $ext => $mime) { - if (!isset($extensions[$ext])) { - $extensions[$ext] = $mime; - } else { - printf(STDERR, "Ignored exist mime type: $ext => $mime\n"); - } + if (!isset($extensions[$ext])) { + $extensions[$ext] = $mime; + } else { + printf(STDERR, "Ignored exist mime type: $ext => $mime\n"); + } } ?> @@ -66,15 +66,15 @@ foreach($additional_mime_maps as $ext => $mime) { #define PHP_CLI_SERVER_MIME_TYPE_MAP_H typedef struct php_cli_server_ext_mime_type_pair { - const char *ext; - const char *mime_type; + const char *ext; + const char *mime_type; } php_cli_server_ext_mime_type_pair; static const php_cli_server_ext_mime_type_pair mime_type_map[] = { <?php foreach ($extensions as $extension => $mime): ?> - { "<?= addcslashes($extension, "\0..\37!@\@\177..\377") ?>", "<?= addcslashes($mime, "\0..\37!@\@\177..\377") ?>" }, + { "<?= addcslashes($extension, "\0..\37!@\@\177..\377") ?>", "<?= addcslashes($mime, "\0..\37!@\@\177..\377") ?>" }, <?php endforeach ?> - { NULL, NULL } + { NULL, NULL } }; #endif /* PHP_CLI_SERVER_MIME_TYPE_MAP_H */ diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index f00d8dee54..bd48afb1f7 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -510,7 +510,7 @@ static int sapi_cli_server_startup(sapi_module_struct *sapi_module) /* {{{ */ if (php_cli_server_workers_max > 1) { zend_long php_cli_server_worker; - + php_cli_server_workers = calloc( php_cli_server_workers_max, sizeof(pid_t)); if (!php_cli_server_workers) { @@ -528,7 +528,7 @@ static int sapi_cli_server_startup(sapi_module_struct *sapi_module) /* {{{ */ if (pid == FAILURE) { /* no more forks allowed, work with what we have ... */ - php_cli_server_workers_max = + php_cli_server_workers_max = php_cli_server_worker + 1; return SUCCESS; } else if (pid == SUCCESS) { @@ -2321,14 +2321,14 @@ static void php_cli_server_dtor(php_cli_server *server) /* {{{ */ int php_cli_server_worker_status; do { - if (waitpid(php_cli_server_workers[php_cli_server_worker], - &php_cli_server_worker_status, + if (waitpid(php_cli_server_workers[php_cli_server_worker], + &php_cli_server_worker_status, 0) == FAILURE) { /* an extremely bad thing happened */ break; } - } while (!WIFEXITED(php_cli_server_worker_status) && + } while (!WIFEXITED(php_cli_server_worker_status) && !WIFSIGNALED(php_cli_server_worker_status)); } diff --git a/sapi/phpdbg/create-test.php b/sapi/phpdbg/create-test.php index e5f7cfe2e9..3e2c8f0437 100755 --- a/sapi/phpdbg/create-test.php +++ b/sapi/phpdbg/create-test.php @@ -32,37 +32,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 = ""; @@ -70,47 +70,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); @@ -127,24 +127,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 3a47c78470..738967f907 100644 --- a/sapi/phpdbg/phpdbg_bp.c +++ b/sapi/phpdbg/phpdbg_bp.c @@ -198,19 +198,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); @@ -841,7 +841,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; @@ -857,10 +857,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; |