Skip to content

Commit

Permalink
Adding a function to upgrade removed basics functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory authored and AD7six committed May 1, 2011
1 parent 02d9e41 commit 6a5d690
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions cake/console/shells/upgrade.php
Expand Up @@ -80,6 +80,68 @@ function i18n() {
$this->_filesRegexpUpdate($patterns);
}

/**
* Upgrade the removed basics functions.
*
* - a(*) -> array(*)
* - e(*) -> echo *
* - ife(*, *, *) -> empty(*) ? * : *
* - a(*) -> array(*)
* - r(*, *, *) -> str_replace(*, *, *)
* - up(*) -> strtoupper(*)
* - low(*, *, *) -> strtolower(*)
* - getMicrotime() -> microtime(true)
*
* @return void
*/
public function basics() {
$this->_paths = array(
APP
);
if (!empty($this->params['plugin'])) {
$this->_paths = array(App::pluginPath($this->params['plugin']));
}
$patterns = array(
array(
'a(*) -> array(*)',
'/a\((.*)\)/',
'array(\1)'
),
array(
'e(*) -> echo *',
'/\be\((.*)\)/',
'echo \1'
),
array(
'ife(*, *, *) -> empty(*) ? * : *',
'/ife\((.*), (.*), (.*)\)/',
'empty(\1) ? \2 : \3'
),
array(
'r(*, *, *) -> str_replace(*, *, *)',
'/\br\(/',
'str_replace('
),
array(
'up(*) -> strtoupper(*)',
'/\bup\(/',
'strtoupper('
),
array(
'low(*) -> strtolower(*)',
'/\blow\(/',
'strtolower('
),
array(
'getMicrotime() -> microtime(true)',
'/getMicrotime\(\)/',
'microtime(true)'
),
);

$this->_filesRegexpUpdate($patterns);
}

/**
* Updates files based on regular expressions.
*
Expand Down Expand Up @@ -165,6 +227,10 @@ function getOptionParser() {
->addSubcommand('helpers', array(
'help' => 'Update calls to helpers.',
'parser' => $subcommandParser
))
->addSubcommand('basics', array(
'help' => 'Update removed basics functions to PHP native functions.',
'parser' => $subcommandParser
));
}
}

0 comments on commit 6a5d690

Please sign in to comment.