Skip to content
Permalink
Browse files

Replace function join (alias) by implode.

Signed-off-by: Mark Story <mark@mark-story.com>
  • Loading branch information...
jrbasso authored and markstory committed Nov 19, 2009
1 parent 1acc60b commit df9e1e0bd1a1445e3854c41f5af6d1f2a7679476
@@ -423,15 +423,15 @@ function env($key) {
/**
* Writes data into file.
*
* If file exists, it will be overwritten. If data is an array, it will be join()ed with an empty string.
* If file exists, it will be overwritten. If data is an array, it will be implode()ed with an empty string.
*
* @param string $fileName File name.
* @param mixed $data String or array.
* @return boolean Success
*/
function file_put_contents($fileName, $data) {
if (is_array($data)) {
$data = join('', $data);
$data = implode('', $data);
}
$res = @fopen($fileName, 'w+b');
@@ -286,7 +286,7 @@ function main($command = null) {
break;
case (preg_match("/^routes\s+show/i", $command, $tmp) == true):
$router =& Router::getInstance();
$this->out(join("\n", Set::extract($router->routes, '{n}.0')));
$this->out(implode("\n", Set::extract($router->routes, '{n}.0')));
break;
case (preg_match("/^route\s+(.*)/i", $command, $tmp) == true):
$this->out(var_export(Router::parse($tmp[1]), true));
@@ -126,7 +126,7 @@ function __interactive($controllerName = false) {
if (file_exists($this->path . $controllerFile .'_controller.php')) {
$question[] = sprintf(__("Warning: Choosing no will overwrite the %sController.", true), $controllerName);
}
$doItInteractive = $this->in(join("\n", $question), array('y','n'), 'y');
$doItInteractive = $this->in(implode("\n", $question), array('y','n'), 'y');
if (strtolower($doItInteractive) == 'y' || strtolower($doItInteractive) == 'yes') {
$this->interactive = true;
@@ -313,7 +313,7 @@ function bakeActions($controllerName, $admin = null, $wannaUseSession = true) {
}
}
if (!empty($compact)) {
$actions .= "\t\t\$this->set(compact(" . join(', ', $compact) . "));\n";
$actions .= "\t\t\$this->set(compact(" . implode(', ', $compact) . "));\n";
}
$actions .= "\t}\n";
$actions .= "\n";
@@ -365,7 +365,7 @@ function bakeActions($controllerName, $admin = null, $wannaUseSession = true) {
}
}
if (!empty($compact)) {
$actions .= "\t\t\$this->set(compact(" . join(',', $compact) . "));\n";
$actions .= "\t\t\$this->set(compact(" . implode(',', $compact) . "));\n";
}
$actions .= "\t}\n";
$actions .= "\n";
@@ -414,13 +414,13 @@ function __buildFiles() {
if ($this->__oneFile === true) {
foreach ($fileInfo as $file => $lines) {
$occured[] = "$file:" . join(';', $lines);
$occured[] = "$file:" . implode(';', $lines);
if (isset($this->__fileVersions[$file])) {
$fileList[] = $this->__fileVersions[$file];
}
}
$occurances = join("\n#: ", $occured);
$occurances = implode("\n#: ", $occured);
$occurances = str_replace($this->path, '', $occurances);
$output = "#: $occurances\n";
$filename = $this->__filename;
@@ -439,12 +439,12 @@ function __buildFiles() {
} else {
foreach ($fileInfo as $file => $lines) {
$filename = $str;
$occured = array("$str:" . join(';', $lines));
$occured = array("$str:" . implode(';', $lines));
if (isset($this->__fileVersions[$str])) {
$fileList[] = $this->__fileVersions[$str];
}
$occurances = join("\n#: ", $occured);
$occurances = implode("\n#: ", $occured);
$occurances = str_replace($this->path, '', $occurances);
$output .= "#: $occurances\n";
@@ -511,9 +511,9 @@ function __writeFiles() {
$fileList = str_replace(array($this->path), '', $fileList);
if (count($fileList) > 1) {
$fileList = "Generated from files:\n# " . join("\n# ", $fileList);
$fileList = "Generated from files:\n# " . implode("\n# ", $fileList);
} elseif (count($fileList) == 1) {
$fileList = 'Generated from file: ' . join('', $fileList);
$fileList = 'Generated from file: ' . implode('', $fileList);
} else {
$fileList = 'No version information was available in the source files.';
}
@@ -535,7 +535,7 @@ function __writeFiles() {
}
}
$fp = fopen($this->__output . $file, 'w');
fwrite($fp, str_replace('--VERSIONS--', $fileList, join('', $content)));
fwrite($fp, str_replace('--VERSIONS--', $fileList, implode('', $content)));
fclose($fp);
}
}
@@ -700,7 +700,7 @@ function bakeTest($className, $useTable = null, $associations = array()) {
}
}
}
$fixture = join(", ", $fixture);
$fixture = implode(", ", $fixture);
$import = $className;
if (isset($this->plugin)) {
@@ -904,24 +904,24 @@ function fixture($model, $useTable = null) {
}
$records[] = "\t\t'$field' => $insert";
unset($value['type']);
$col .= join(', ', $schema->__values($value));
$col .= implode(', ', $schema->__values($value));
} else {
$col = "\t\t'indexes' => array(";
$props = array();
foreach ((array)$value as $key => $index) {
$props[] = "'{$key}' => array(" . join(', ', $schema->__values($index)) . ")";
$props[] = "'{$key}' => array(" . implode(', ', $schema->__values($index)) . ")";
}
$col .= join(', ', $props);
$col .= implode(', ', $props);
}
$col .= ")";
$cols[] = $col;
}
$out .= join(",\n", $cols);
$out .= implode(",\n", $cols);
}
$out .= "\n\t);\n";
}
}
$records = join(",\n", $records);
$records = implode(",\n", $records);
$out .= "\tvar \$records = array(array(\n$records\n\t));\n";
$out .= "}\n";
$path = TESTS . DS . 'fixtures' . DS;
@@ -79,7 +79,7 @@ function display() {
$title = Inflector::humanize($path[$count - 1]);
}
$this->set(compact('page', 'subpage', 'title'));
$this->render(join('/', $path));
$this->render(implode('/', $path));
}
}
@@ -327,7 +327,7 @@ function loginRequest($options = array()) {
$out[] = 'opaque="' . md5($options['realm']).'"';
}
return $auth . ' ' . join(',', $out);
return $auth . ' ' . implode(',', $out);
}
/**
* Parses an HTTP digest authentication response, and returns an array of the data, or null on failure.
@@ -79,7 +79,7 @@ function display() {
$title = Inflector::humanize($path[$count - 1]);
}
$this->set(compact('page', 'subpage', 'title'));
$this->render(join('/', $path));
$this->render(implode('/', $path));
}
}
@@ -275,7 +275,7 @@ function trace($options = array()) {
foreach ($next['args'] as $arg) {
$args[] = Debugger::exportVar($arg);
}
$function .= join(', ', $args);
$function .= implode(', ', $args);
}
$function .= ')';
}
@@ -297,7 +297,7 @@ function trace($options = array()) {
if ($options['format'] == 'array' || $options['format'] == 'points') {
return $back;
}
return join("\n", $back);
return implode("\n", $back);
}
/**
* Shortens file paths by replacing the application base path with 'APP', and the CakePHP core
@@ -406,7 +406,7 @@ function exportVar($var, $recursion = 0) {
if (count($vars) > 0) {
$n = "\n";
}
return $out . join(",", $vars) . "{$n})";
return $out . implode(",", $vars) . "{$n})";
break;
case 'resource':
return strtolower(gettype($var));
@@ -444,7 +444,7 @@ function __object($var) {
$out[] = "$className::$$key = " . $value;
}
}
return join("\n", $out);
return implode("\n", $out);
}
/**
* Handles object conversion to debug string.
@@ -217,7 +217,7 @@ function markedSnippets($words, $string, $max_snippets = 5) {
if (count($snips) > $max_snippets) {
$snips = array_slice($snips, 0, $max_snippets);
}
$joined = join(' <b>...</b> ', $snips);
$joined = implode(' <b>...</b> ', $snips);
$snips = $joined ? "<b>...</b> {$joined} <b>...</b>" : substr($string, 0, 80) . '<b>...</b>';
return $this->colorMark($words, $snips);
}
@@ -738,7 +738,7 @@ function buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') {
$request['uri'] = $this->buildUri($request['uri'], '/%path?%query');
if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) {
trigger_error(sprintf(__('HttpSocket::buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', true), join(',', $asteriskMethods)), E_USER_WARNING);
trigger_error(sprintf(__('HttpSocket::buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', true), implode(',', $asteriskMethods)), E_USER_WARNING);
return false;
}
return $request['method'].' '.$request['uri'].' '.$versionToken.$this->lineBreak;
@@ -776,7 +776,7 @@ function buildHeader($header, $mode = 'standard') {
$returnHeader = '';
foreach ($header as $field => $contents) {
if (is_array($contents) && $mode == 'standard') {
$contents = join(',', $contents);
$contents = implode(',', $contents);
}
foreach ((array)$contents as $content) {
$contents = preg_replace("/\r\n(?![\t ])/", "\r\n ", $content);
@@ -921,7 +921,7 @@ function loadCookies() {
* @todo Test $chars parameter
*/
function unescapeToken($token, $chars = null) {
$regex = '/"(['.join('', $this->__tokenEscapeChars(true, $chars)).'])"/';
$regex = '/"(['.implode('', $this->__tokenEscapeChars(true, $chars)).'])"/';
$token = preg_replace($regex, '\\1', $token);
return $token;
}
@@ -934,7 +934,7 @@ function unescapeToken($token, $chars = null) {
* @todo Test $chars parameter
*/
function escapeToken($token, $chars = null) {
$regex = '/(['.join('', $this->__tokenEscapeChars(true, $chars)).'])/';
$regex = '/(['.implode('', $this->__tokenEscapeChars(true, $chars)).'])/';
$token = preg_replace($regex, '"\\1"', $token);
return $token;
}
@@ -243,8 +243,8 @@ function pluralize($word) {
extract($_this->pluralRules);
if (!isset($regexUninflected) || !isset($regexIrregular)) {
$regexUninflected = __enclose(join( '|', $uninflected));
$regexIrregular = __enclose(join( '|', array_keys($irregular)));
$regexUninflected = __enclose(implode( '|', $uninflected));
$regexIrregular = __enclose(implode( '|', array_keys($irregular)));
$_this->pluralRules['regexUninflected'] = $regexUninflected;
$_this->pluralRules['regexIrregular'] = $regexIrregular;
}
@@ -383,8 +383,8 @@ function singularize($word) {
extract($_this->singularRules);
if (!isset($regexUninflected) || !isset($regexIrregular)) {
$regexUninflected = __enclose(join( '|', $uninflected));
$regexIrregular = __enclose(join( '|', array_keys($irregular)));
$regexUninflected = __enclose(implode( '|', $uninflected));
$regexIrregular = __enclose(implode( '|', array_keys($irregular)));
$_this->singularRules['regexUninflected'] = $regexUninflected;
$_this->singularRules['regexIrregular'] = $regexIrregular;
}
@@ -283,7 +283,7 @@ function containments(&$Model, $contain, $containments = array(), $throwErrors =
if (strpos($name, '.') !== false) {
$chain = explode('.', $name);
$name = array_shift($chain);
$children = array(join('.', $chain) => $children);
$children = array(implode('.', $chain) => $children);
}
$children = (array)$children;
@@ -591,7 +591,7 @@ function renderStatement($type, $data) {
foreach (array('columns', 'indexes') as $var) {
if (is_array(${$var})) {
${$var} = "\t" . join(",\n\t", array_filter(${$var}));
${$var} = "\t" . implode(",\n\t", array_filter(${$var}));
}
}
return "CREATE TABLE {$table} (\n{$columns});\n{$indexes}";
@@ -719,7 +719,7 @@ function buildIndex($indexes, $table = null) {
$out = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE";
if (is_array($value['column'])) {
$value['column'] = join(', ', array_map(array(&$this, 'name'), $value['column']));
$value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column']));
} else {
$value['column'] = $this->name($value['column']);
}
@@ -141,7 +141,7 @@ function update(&$model, $fields = array(), $values = null, $conditions = null)
$alias = $joins = false;
$fields = $this->_prepareUpdateFields($model, $combined, empty($conditions), !empty($conditions));
$fields = join(', ', $fields);
$fields = implode(', ', $fields);
$table = $this->fullTableName($model);
if (!empty($conditions)) {
@@ -281,7 +281,7 @@ function alterSchema($compare, $table = null) {
}
}
$colList = array_merge($colList, $this->_alterIndexes($curTable, $indexes));
$out .= "\t" . join(",\n\t", $colList) . ";\n\n";
$out .= "\t" . implode(",\n\t", $colList) . ";\n\n";
}
}
return $out;
@@ -339,7 +339,7 @@ function _alterIndexes($table, $indexes) {
}
}
if (is_array($value['column'])) {
$out .= 'KEY '. $name .' (' . join(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
$out .= 'KEY '. $name .' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')';
} else {
$out .= 'KEY '. $name .' (' . $this->name($value['column']) . ')';
}
@@ -358,7 +358,7 @@ function _alterIndexes($table, $indexes) {
function insertMulti($table, $fields, $values) {
$table = $this->fullTableName($table);
if (is_array($fields)) {
$fields = join(', ', array_map(array(&$this, 'name'), $fields));
$fields = implode(', ', array_map(array(&$this, 'name'), $fields));
}
$values = implode(', ', $values);
$this->query("INSERT INTO {$table} ({$fields}) VALUES {$values}");
@@ -704,7 +704,7 @@ function alterSchema($compare, $table = null) {
break;
}
}
$out .= "\t" . join(",\n\t", $colList) . ";\n\n";
$out .= "\t" . implode(",\n\t", $colList) . ";\n\n";
}
}
return $out;
@@ -925,7 +925,7 @@ function renderStatement($type, $data) {
case 'schema':
foreach (array('columns', 'indexes') as $var) {
if (is_array(${$var})) {
${$var} = "\t" . join(",\n\t", array_filter(${$var}));
${$var} = "\t" . implode(",\n\t", array_filter(${$var}));
}
}
if (trim($indexes) != '') {
@@ -977,7 +977,7 @@ function queryAssociation(&$model, &$linkModel, $type, $association, $assocData,
$fetch = array();
$ins = array_chunk($ins, 1000);
foreach ($ins as $i) {
$q = str_replace('{$__cakeID__$}', join(', ', $i), $query);
$q = str_replace('{$__cakeID__$}', implode(', ', $i), $query);
$q = str_replace('= (', 'IN (', $q);
$res = $this->fetchAll($q, $model->cacheQueries, $model->alias);
$fetch = array_merge($fetch, $res);
@@ -1021,7 +1021,7 @@ function queryAssociation(&$model, &$linkModel, $type, $association, $assocData,
$fetch = array();
$ins = array_chunk($ins, 1000);
foreach ($ins as $i) {
$q = str_replace('{$__cakeID__$}', '(' .join(', ', $i) .')', $query);
$q = str_replace('{$__cakeID__$}', '(' .implode(', ', $i) .')', $query);
$q = str_replace('= (', 'IN (', $q);
$q = str_replace(' WHERE 1 = 1', '', $q);
Oops, something went wrong.

0 comments on commit df9e1e0

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.