mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
substr() optimizations
This commit is contained in:
parent
349c1755d8
commit
e2a46f76c7
6 changed files with 8 additions and 10 deletions
|
@ -398,8 +398,8 @@ class TestTask extends BakeTask {
|
|||
protected function _addFixture($name) {
|
||||
$parent = get_parent_class($name);
|
||||
$prefix = 'app.';
|
||||
if (strtolower($parent) != 'appmodel' && strtolower(substr($parent, - 8)) == 'appmodel') {
|
||||
$pluginName = substr($parent, 0, strlen($parent) - 8);
|
||||
if (strtolower($parent) != 'appmodel' && strtolower(substr($parent, -8)) == 'appmodel') {
|
||||
$pluginName = substr($parent, 0, -8);
|
||||
$prefix = 'plugin.' . Inflector::underscore($pluginName) . '.';
|
||||
}
|
||||
$fixture = $prefix . Inflector::underscore($name);
|
||||
|
@ -452,7 +452,7 @@ class TestTask extends BakeTask {
|
|||
$construct = "new $fullClassName();\n";
|
||||
}
|
||||
if ($type == 'controller') {
|
||||
$className = substr($fullClassName, 0, strlen($fullClassName) - 10);
|
||||
$className = substr($fullClassName, 0, -10);
|
||||
$construct = "new Test$fullClassName();\n";
|
||||
$post = "\$this->{$className}->constructClasses();\n";
|
||||
}
|
||||
|
|
|
@ -234,7 +234,8 @@ class UpgradeShell extends AppShell {
|
|||
$helpers = array_merge($pluginHelpers, $helpers);
|
||||
foreach ($helpers as $helper) {
|
||||
$helper = preg_replace('/Helper$/', '', $helper);
|
||||
$oldHelper = strtolower(substr($helper, 0, 1)) . substr($helper, 1);
|
||||
$oldHelper = $helper;
|
||||
$oldHelper{0} = strtolower($oldHelper{0});
|
||||
$patterns[] = array(
|
||||
"\${$oldHelper} to \$this->{$helper}",
|
||||
"/\\\${$oldHelper}->/",
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
/**
|
||||
* Include files
|
||||
*/
|
||||
App::uses('CakeResponse', 'Network');
|
||||
App::uses('ClassRegistry', 'Utility');
|
||||
App::uses('ComponentCollection', 'Controller');
|
||||
|
|
|
@ -304,7 +304,7 @@ class ContainableBehavior extends ModelBehavior {
|
|||
$option = 'fields';
|
||||
$val = array($key);
|
||||
if ($key{0} == '(') {
|
||||
$val = preg_split('/\s*,\s*/', substr(substr($key, 1), 0, -1));
|
||||
$val = preg_split('/\s*,\s*/', substr($key, 1, -1));
|
||||
} elseif (preg_match('/ASC|DESC$/', $key)) {
|
||||
$option = 'order';
|
||||
$val = $Model->{$name}->alias . '.' . $key;
|
||||
|
|
|
@ -786,7 +786,7 @@ class FormHelper extends AppHelper {
|
|||
$text = $fieldName;
|
||||
}
|
||||
if (substr($text, -3) == '_id') {
|
||||
$text = substr($text, 0, strlen($text) - 3);
|
||||
$text = substr($text, 0, -3);
|
||||
}
|
||||
$text = __(Inflector::humanize(Inflector::underscore($text)));
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ function env($key) {
|
|||
if (!strpos($name, '.php')) {
|
||||
$offset = 4;
|
||||
}
|
||||
return substr($filename, 0, strlen($filename) - (strlen($name) + $offset));
|
||||
return substr($filename, 0, -(strlen($name) + $offset));
|
||||
break;
|
||||
case 'PHP_SELF':
|
||||
return str_replace(env('DOCUMENT_ROOT'), '', env('SCRIPT_FILENAME'));
|
||||
|
|
Loading…
Add table
Reference in a new issue