From 4f7f5e4b1fd1077ad134860b32203810ef24c0ce Mon Sep 17 00:00:00 2001 From: Christian Schneider Date: Wed, 13 Jan 2021 16:21:03 +0100 Subject: Unified join to always use implode --- it.class | 10 +++++----- it_auto_prepend.php | 2 +- it_dbi.class | 10 +++++----- it_dbi_postgres.class | 2 +- it_debug.class | 2 +- it_html.class | 4 ++-- it_mail.class | 8 ++++---- it_pipe.class | 8 ++++---- it_syntaxconverter.class | 2 +- it_url.class | 2 +- itjs.class | 2 +- test/it_url_slow.t | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/it.class b/it.class index 3351002..84e4fde 100644 --- a/it.class +++ b/it.class @@ -54,7 +54,7 @@ static function createconfig($p = array()) $code[] = "static \$$name = " . var_export($value, true) . ";"; $code[] = "}"; - eval(join("\n", $code)); + eval(implode("\n", $code)); } @@ -174,7 +174,7 @@ static function error($p = array(), $extra = null) if ($_SERVER['REMOTE_ADDR']) $url = "http://" . it::replace([':443$' => ""], $_SERVER['HTTP_HOST']) . $_SERVER['REQUEST_URI']; # we ignore https for easier debugging else - $url = $_SERVER['SCRIPT_NAME'] . " " . join(" ", array_slice($GLOBALS['argv'], 1)) . " (pwd " . $_SERVER['PWD'] . ")"; + $url = $_SERVER['SCRIPT_NAME'] . " " . implode(" ", array_slice($GLOBALS['argv'], 1)) . " (pwd " . $_SERVER['PWD'] . ")"; $gods = strtr(trim(@file_get_contents($GLOBALS['ULTRAHOME'] . "/.diffnotice")), array("\n"=>', ')); # NOPHPLINT if (!$p['to']) @@ -709,7 +709,7 @@ static function shell_command(/* $cmd, $values1 = array(), ... */) $parts[] = it::_exec_quotevalue($value, "cmd=$cmd key=$key val=$value"); } - $replacements[$tag] = join(" ", $parts); + $replacements[$tag] = implode(" ", $parts); } $cmd = strtr($cmd, (array)$replacements); # Use strtr behaviour of going through source string once @@ -1136,9 +1136,9 @@ static function file_put($filename, $data, $p = array()) $filename = it::safe_filename($filename); if ($p['keyval']) - $data = join("", it::map('"$k\t$v\n"', $data)); + $data = implode("", it::map('"$k\t$v\n"', $data)); else if ($p['lines']) - $data = count((array)$data) ? join("\n", (array)$data) ."\n" : ""; + $data = count((array)$data) ? implode("\n", (array)$data) ."\n" : ""; if ($p['mkdir'] && $filename != "-") @mkdir(dirname($filename)); diff --git a/it_auto_prepend.php b/it_auto_prepend.php index 8589f9f..c758226 100644 --- a/it_auto_prepend.php +++ b/it_auto_prepend.php @@ -148,7 +148,7 @@ function it_convert($source) $parts = explode("/", dirname($converted)); for ($i = 1; $i <= count($parts); $i++) - @mkdir(join("/", array_slice($parts, 0, $i)), 0700); + @mkdir(implode("/", array_slice($parts, 0, $i)), 0700); if ($changed = $converter->changes) { diff --git a/it_dbi.class b/it_dbi.class index b681102..4389689 100644 --- a/it_dbi.class +++ b/it_dbi.class @@ -445,14 +445,14 @@ function _where($params) foreach ((array)$value as $val) $parts[] = "CONCAT(',',$field,',') LIKE " . $this->escape_string("%,$val,%"); - $query .= $sep . "$field IS NOT NULL AND (" . join(" OR ", $parts) . ")"; # Check for IS NOT NULL to take advantage of index + $query .= $sep . "$field IS NOT NULL AND (" . implode(" OR ", $parts) . ")"; # Check for IS NOT NULL to take advantage of index } else $query .= $sep . "TRUE"; break; case 'MATCH': - $qval = join(' ', (array)$value); + $qval = implode(' ', (array)$value); $query .= "$sep$op ($field) AGAINST (" . $this->escape_string($qval) . " IN BOOLEAN MODE)"; break; @@ -467,7 +467,7 @@ function _where($params) foreach ($value as $val) $qvals[] = $this->escape_string($val); - $query .= "$sep$field $op (" . join(",", $qvals) . ")"; # null is mapped to '' + $query .= "$sep$field $op (" . implode(",", $qvals) . ")"; # null is mapped to '' } else $query .= $sep . (($op == 'IN') ? "FALSE" : "TRUE"); @@ -941,7 +941,7 @@ function _get_field_info() if (preg_match('/^(tiny|small|medium|)int|^float|^double/', $field['Type'])) $this->_convertfunc[$name] = it::match('int', $field['Type']) ? "intval" : "floatval"; } - $this->_fieldnames = "," . join(",", array_keys((array)$this->_fields)) . ","; + $this->_fieldnames = "," . implode(",", array_keys((array)$this->_fields)) . ","; # Consider all fields which have _{localized_defaultlanguage} suffix as localized foreach (preg_grep('/_' . $this->_p['localized_defaultlanguage'] . '$/', array_keys((array)$this->_fields)) as $field) @@ -1125,7 +1125,7 @@ function _query($query, $p) } while ($warning->next() && ++$checked < 20); if ($messages) - it::error(['title' => "Mysql warning: " . $messages[0], 'body' => "$query\n\n" . join("\n", $messages) . "\n"]); + it::error(['title' => "Mysql warning: " . $messages[0], 'body' => "$query\n\n" . implode("\n", $messages) . "\n"]); } return $result; diff --git a/it_dbi_postgres.class b/it_dbi_postgres.class index 6ca4b50..385ac7e 100644 --- a/it_dbi_postgres.class +++ b/it_dbi_postgres.class @@ -135,7 +135,7 @@ function _query($query, $p) } while ($warning->next() && ++$checked < 20); if ($messages) - it::error(['title' => "Mysql warning: " . $messages[0], 'body' => "$query\n\n" . join("\n", $messages) . "\n"]); + it::error(['title' => "Mysql warning: " . $messages[0], 'body' => "$query\n\n" . implode("\n", $messages) . "\n"]); } */ diff --git a/it_debug.class b/it_debug.class index 12fb254..8eb253e 100644 --- a/it_debug.class +++ b/it_debug.class @@ -188,7 +188,7 @@ static function backtrace($p = array()) } } - return join(" ", (array)$result); + return implode(" ", (array)$result); } static function set($debug_string) diff --git a/it_html.class b/it_html.class index b27c696..da8f576 100644 --- a/it_html.class +++ b/it_html.class @@ -132,7 +132,7 @@ function __construct($p = array()) $code[$func] = "function $func() { \$args = func_get_args(); return call_user_func_array(array(&\$GLOBALS['{$this->p['name']}'], '$func'), \$args); }"; } - eval(join('', (array)$code)); + eval(implode('', (array)$code)); } @@ -255,7 +255,7 @@ function body($args) $toggled_host = preg_replace("/\.([^.]*)\.([^.]*)\.([^.]*)$/", ".$var.\$1.\$2.\$3", $_SERVER['HTTP_HOST']); $debug_links[] = a(array('href' => U('http://' . $toggled_host . $_SERVER['REQUEST_URI']), 'style' => 'font-weight:' . (EDC($var) ? 'bold' : 'normal') . ';'), $var); } - $args[] = div(array('style' => 'position:fixed; bottom:0; z-index:9999; font-family:monospace'), "Debugvars: " . join(" ", $debug_links)); + $args[] = div(array('style' => 'position:fixed; bottom:0; z-index:9999; font-family:monospace'), "Debugvars: " . implode(" ", $debug_links)); } return $this->head() . $this->_tag('body', $args); diff --git a/it_mail.class b/it_mail.class index 0c5cb4a..8b71023 100644 --- a/it_mail.class +++ b/it_mail.class @@ -183,14 +183,14 @@ function add_file($filename, $p = array(), $legacy_name = null) */ function send($p = array()) { - $to = join(",", $this->to); + $to = implode(",", $this->to); $headers = array(); if (count($this->cc) > 0) - $headers[] = "Cc: " . join(",", $this->cc); + $headers[] = "Cc: " . implode(",", $this->cc); if (count($this->bcc) > 0) - $headers[] = "Bcc: " . join(",", $this->bcc); + $headers[] = "Bcc: " . implode(",", $this->bcc); for ($i = 0; $i < count($this->header_names); $i++) $headers[] = $this->header_names[$i] . ': ' . $this->header_values[$i]; @@ -289,7 +289,7 @@ function send($p = array()) if (it::is_live() || EDC('forcemail') || $p['forcemail']) { - if (($result = mail($to, $this->header_escape($this->subject), $text, join("\n", $headers), $this->flags)) === false) + if (($result = mail($to, $this->header_escape($this->subject), $text, implode("\n", $headers), $this->flags)) === false) it::error(array('title' => "failed sending mail to $to subject $this->subject", 'body' => D($text, $headers, $this->flags))); return $result; } diff --git a/it_pipe.class b/it_pipe.class index 967cc77..3153dae 100644 --- a/it_pipe.class +++ b/it_pipe.class @@ -42,7 +42,7 @@ function __call($name, $params) function __toString() { - return is_array($this->lines) ? join("\n", $this->lines) . "\n" : ""; + return is_array($this->lines) ? implode("\n", $this->lines) . "\n" : ""; } @@ -117,7 +117,7 @@ function utf8() function cut($picks) { foreach ($this->lines as $idx => $line) - $this->lines[$idx] = join("\t", it::filter_keys(explode("\t", $line), $picks, ['reorder' => true])); + $this->lines[$idx] = implode("\t", it::filter_keys(explode("\t", $line), $picks, ['reorder' => true])); return $this; } @@ -243,7 +243,7 @@ function pipe($cmd, ...$args) $descriptors = array(0 => array("pipe", "r"), 1 => array("pipe", "w")); $process = proc_open($cmd, $descriptors, $pipes); - fwrite($pipes[0], join("\n", $this->lines) . ($this->lines ? "\n" :"")); + fwrite($pipes[0], implode("\n", $this->lines) . ($this->lines ? "\n" :"")); fclose($pipes[0]); $out = stream_get_contents($pipes[1]); @@ -261,7 +261,7 @@ function pipe($cmd, ...$args) */ function write($fn = null, $append = false) { - it::file_put_contents($fn === null ? "php://stdout" : $fn, $this->lines ? join("\n", $this->lines) . "\n" : "", $append ? FILE_APPEND : 0); + it::file_put_contents($fn === null ? "php://stdout" : $fn, $this->lines ? implode("\n", $this->lines) . "\n" : "", $append ? FILE_APPEND : 0); return $this; } diff --git a/it_syntaxconverter.class b/it_syntaxconverter.class index bca1fb8..a40b44b 100644 --- a/it_syntaxconverter.class +++ b/it_syntaxconverter.class @@ -415,7 +415,7 @@ function text($tokens) foreach ($data as $element) $list[] .= $this->text($element); - $result .= "(" . join(",", $list) . ")"; + $result .= "(" . implode(",", $list) . ")"; } else $result .= $data; diff --git a/it_url.class b/it_url.class index bddbdb8..f4dc05f 100644 --- a/it_url.class +++ b/it_url.class @@ -850,7 +850,7 @@ static function encode($str) */ static function params($params, $keys = null) { - return join("&", it_url::_params($params, $keys)); + return implode("&", it_url::_params($params, $keys)); } static function _params($params, $keys = null, $finalize = true) diff --git a/itjs.class b/itjs.class index 0ccbebf..c2f7f99 100644 --- a/itjs.class +++ b/itjs.class @@ -139,7 +139,7 @@ static function checksum($fnlist, $p = array()) $filenames[] = !file_exists($filename) && file_exists($t = it::replace(array('^/www/[^/]*' => "/www/lib.search.ch"), $filename)) ? $t : $filename; $additional = json_encode($p['additional_data']); - $key = "itjs_" . md5(join("", it::map('"$v" . @filemtime("$v")', $filenames)) . $additional); + $key = "itjs_" . md5(implode("", it::map('"$v" . @filemtime("$v")', $filenames)) . $additional); if ($filenames && $p['short_expire'] && (time() - max(@array_map('filemtime', $filenames)) < 60)) return "-"; # trigger short expire, our file may not yet be up to date on other slaves diff --git a/test/it_url_slow.t b/test/it_url_slow.t index 3462ce2..51da6b9 100755 --- a/test/it_url_slow.t +++ b/test/it_url_slow.t @@ -32,7 +32,7 @@ if (!$res || !$res2) handle_server( is( it_url::get('http://localhost:8000/slow_response'), - join('', it::map('"Testserver slow output $v\n"', range(0, 5))), + implode('', it::map('"Testserver slow output $v\n"', range(0, 5))), 'it_url::get() waits for slow response with continuous output' ) ); -- cgit v1.2.3