mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-17 04:18:24 +00:00
Adding a function to upgrade removed basics functions.
This commit is contained in:
parent
05bc08d932
commit
2253bf1942
1 changed files with 66 additions and 0 deletions
|
@ -80,6 +80,68 @@ class UpgradeShell extends Shell {
|
|||
$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.
|
||||
*
|
||||
|
@ -165,6 +227,10 @@ class UpgradeShell extends Shell {
|
|||
->addSubcommand('helpers', array(
|
||||
'help' => 'Update calls to helpers.',
|
||||
'parser' => $subcommandParser
|
||||
))
|
||||
->addSubcommand('basics', array(
|
||||
'help' => 'Update removed basics functions to PHP native functions.',
|
||||
'parser' => $subcommandParser
|
||||
));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue