Skip to content

Commit

Permalink
Replace function join (alias) by implode.
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Story <mark@mark-story.com>
  • Loading branch information
jrbasso authored and markstory committed Nov 21, 2009
1 parent 1acc60b commit df9e1e0
Show file tree
Hide file tree
Showing 33 changed files with 111 additions and 111 deletions.
4 changes: 2 additions & 2 deletions cake/basics.php
Expand Up @@ -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');

Expand Down
2 changes: 1 addition & 1 deletion cake/console/libs/console.php
Expand Up @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions cake/console/libs/tasks/controller.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
14 changes: 7 additions & 7 deletions cake/console/libs/tasks/extract.php
Expand Up @@ -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;
Expand All @@ -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";

Expand Down Expand Up @@ -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.';
}
Expand All @@ -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);
}
}
Expand Down
12 changes: 6 additions & 6 deletions cake/console/libs/tasks/model.php
Expand Up @@ -700,7 +700,7 @@ function bakeTest($className, $useTable = null, $associations = array()) {
}
}
}
$fixture = join(", ", $fixture);
$fixture = implode(", ", $fixture);

$import = $className;
if (isset($this->plugin)) {
Expand Down Expand Up @@ -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;
Expand Down
Expand Up @@ -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));
}
}

Expand Down
2 changes: 1 addition & 1 deletion cake/libs/controller/components/security.php
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/controller/pages_controller.php
Expand Up @@ -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));
}
}

Expand Down
8 changes: 4 additions & 4 deletions cake/libs/debugger.php
Expand Up @@ -275,7 +275,7 @@ function trace($options = array()) {
foreach ($next['args'] as $arg) {
$args[] = Debugger::exportVar($arg);
}
$function .= join(', ', $args);
$function .= implode(', ', $args);
}
$function .= ')';
}
Expand All @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/flay.php
Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions cake/libs/http_socket.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions cake/libs/inflector.php
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion cake/libs/model/behaviors/containable.php
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions cake/libs/model/datasources/dbo/dbo_mssql.php
Expand Up @@ -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}";
Expand Down Expand Up @@ -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']);
}
Expand Down
8 changes: 4 additions & 4 deletions cake/libs/model/datasources/dbo/dbo_mysql.php
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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']) . ')';
}
Expand All @@ -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}");
Expand Down
8 changes: 4 additions & 4 deletions cake/libs/model/datasources/dbo/dbo_oracle.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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) != '') {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit df9e1e0

Please sign in to comment.