From 52ecccb1a295d4605e8777162c5017d23a5eec3c Mon Sep 17 00:00:00 2001 From: euromark Date: Mon, 5 Jan 2015 01:00:57 +0100 Subject: [PATCH] App::uses and usage replacements for String => CakeText. --- lib/Cake/Console/Command/SchemaShell.php | 4 ++-- lib/Cake/Console/Command/Task/FixtureTask.php | 2 +- lib/Cake/Console/Command/Task/ProjectTask.php | 4 ++-- lib/Cake/Console/HelpFormatter.php | 12 ++++++------ lib/Cake/Console/Shell.php | 4 ++-- lib/Cake/Controller/Component/SecurityComponent.php | 2 +- lib/Cake/Core/Configure.php | 4 ++-- lib/Cake/Model/Behavior/TranslateBehavior.php | 2 +- lib/Cake/Model/Datasource/Database/Sqlite.php | 4 ++-- lib/Cake/Model/Datasource/DboSource.php | 6 +++--- lib/Cake/Model/Model.php | 10 +++++----- lib/Cake/Network/Email/CakeEmail.php | 4 ++-- .../Case/Model/Behavior/TreeBehaviorUuidTest.php | 4 ++-- lib/Cake/Utility/Debugger.php | 12 ++++++------ lib/Cake/Utility/Hash.php | 8 ++++---- lib/Cake/Utility/Security.php | 4 ++-- lib/Cake/Utility/Set.php | 4 ++-- lib/Cake/View/Helper/TextHelper.php | 12 ++++++------ 18 files changed, 51 insertions(+), 51 deletions(-) diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 6f77220d8..16abb600d 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -122,7 +122,7 @@ class SchemaShell extends AppShell { if ($this->params['force']) { $options['models'] = false; } elseif (!empty($this->params['models'])) { - $options['models'] = String::tokenize($this->params['models']); + $options['models'] = CakeText::tokenize($this->params['models']); } $snapshot = false; @@ -151,7 +151,7 @@ class SchemaShell extends AppShell { Configure::write('Cache.disable', $cacheDisable); if (!empty($this->params['exclude']) && !empty($content)) { - $excluded = String::tokenize($this->params['exclude']); + $excluded = CakeText::tokenize($this->params['exclude']); foreach ($excluded as $table) { unset($content['tables'][$table]); } diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index 65404fb1c..b20c22b4b 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -340,7 +340,7 @@ class FixtureTask extends BakeTask { isset($fieldInfo['length']) && $fieldInfo['length'] == 36 ); if ($isPrimaryUuid) { - $insert = String::uuid(); + $insert = CakeText::uuid(); } else { $insert = "Lorem ipsum dolor sit amet"; if (!empty($fieldInfo['length'])) { diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index 4763b2876..df1ab19db 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -18,7 +18,7 @@ App::uses('AppShell', 'Console/Command'); App::uses('File', 'Utility'); App::uses('Folder', 'Utility'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('Security', 'Utility'); /** @@ -212,7 +212,7 @@ class ProjectTask extends AppShell { } foreach ($Folder->messages() as $message) { - $this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE); + $this->out(CakeText::wrap(' * ' . $message), 1, Shell::VERBOSE); } return true; diff --git a/lib/Cake/Console/HelpFormatter.php b/lib/Cake/Console/HelpFormatter.php index 140c289bd..3a8fac98f 100644 --- a/lib/Cake/Console/HelpFormatter.php +++ b/lib/Cake/Console/HelpFormatter.php @@ -14,7 +14,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); /** * HelpFormatter formats help for console shells. Can format to either @@ -64,7 +64,7 @@ class HelpFormatter { $out = array(); $description = $parser->description(); if (!empty($description)) { - $out[] = String::wrap($description, $width); + $out[] = CakeText::wrap($description, $width); $out[] = ''; } $out[] = __d('cake_console', 'Usage:'); @@ -76,7 +76,7 @@ class HelpFormatter { $out[] = ''; $max = $this->_getMaxLength($subcommands) + 2; foreach ($subcommands as $command) { - $out[] = String::wrap($command->help($max), array( + $out[] = CakeText::wrap($command->help($max), array( 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 @@ -93,7 +93,7 @@ class HelpFormatter { $out[] = __d('cake_console', 'Options:'); $out[] = ''; foreach ($options as $option) { - $out[] = String::wrap($option->help($max), array( + $out[] = CakeText::wrap($option->help($max), array( 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 @@ -108,7 +108,7 @@ class HelpFormatter { $out[] = __d('cake_console', 'Arguments:'); $out[] = ''; foreach ($arguments as $argument) { - $out[] = String::wrap($argument->help($max), array( + $out[] = CakeText::wrap($argument->help($max), array( 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 @@ -118,7 +118,7 @@ class HelpFormatter { } $epilog = $parser->epilog(); if (!empty($epilog)) { - $out[] = String::wrap($epilog, $width); + $out[] = CakeText::wrap($epilog, $width); $out[] = ''; } return implode("\n", $out); diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 67e3c2eab..6315a4ef9 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -584,11 +584,11 @@ class Shell extends Object { * @param string $text Text the text to format. * @param string|int|array $options Array of options to use, or an integer to wrap the text to. * @return string Wrapped / indented text - * @see String::wrap() + * @see CakeText::wrap() * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText */ public function wrapText($text, $options = array()) { - return String::wrap($text, $options); + return CakeText::wrap($text, $options); } /** diff --git a/lib/Cake/Controller/Component/SecurityComponent.php b/lib/Cake/Controller/Component/SecurityComponent.php index 68255eb2e..cb41cf7ff 100644 --- a/lib/Cake/Controller/Component/SecurityComponent.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -17,7 +17,7 @@ */ App::uses('Component', 'Controller'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('Hash', 'Utility'); App::uses('Security', 'Utility'); diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 88eedfd51..4c26eca1b 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -103,10 +103,10 @@ class Configure { self::$_values['Exception'] ); - // Preload Debugger + String in case of E_STRICT errors when loading files. + // Preload Debugger + CakeText in case of E_STRICT errors when loading files. if (self::$_values['debug'] > 0) { class_exists('Debugger'); - class_exists('String'); + class_exists('CakeText'); } } } diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index 1b0be00ab..3ba00ff75 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -140,7 +140,7 @@ class TranslateBehavior extends ModelBehavior { unset($this->_joinTable, $this->_runtimeModel); return $query; } elseif (is_string($query['fields'])) { - $query['fields'] = String::tokenize($query['fields']); + $query['fields'] = CakeText::tokenize($query['fields']); } $fields = array_merge( diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 37c3787a8..e73947448 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -17,7 +17,7 @@ */ App::uses('DboSource', 'Model/Datasource'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); /** * DBO implementation for the SQLite3 DBMS. @@ -303,7 +303,7 @@ class Sqlite extends DboSource { if (stripos($querystring, 'SELECT') === 0 && stripos($querystring, 'FROM') > 0) { $selectpart = substr($querystring, 7); $selects = array(); - foreach (String::tokenize($selectpart, ',', '(', ')') as $part) { + foreach (CakeText::tokenize($selectpart, ',', '(', ')') as $part) { $fromPos = stripos($part, ' FROM '); if ($fromPos !== false) { $selects[] = trim(substr($part, 0, $fromPos)); diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index c18f3318a..b17cf3d2b 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -17,7 +17,7 @@ */ App::uses('DataSource', 'Model/Datasource'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('View', 'View'); /** @@ -2513,7 +2513,7 @@ class DboSource extends DataSource { if ($allFields) { $fields = array_keys($Model->schema()); } elseif (!is_array($fields)) { - $fields = String::tokenize($fields); + $fields = CakeText::tokenize($fields); } $fields = array_values(array_filter($fields)); $allFields = $allFields || in_array('*', $fields) || in_array($Model->alias . '.*', $fields); @@ -2813,7 +2813,7 @@ class DboSource extends DataSource { } if ($bound) { - return String::insert($key . ' ' . trim($operator), $value); + return CakeText::insert($key . ' ' . trim($operator), $value); } if (!preg_match($operatorMatch, trim($operator))) { diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index dee55cffd..dcb481093 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -20,7 +20,7 @@ App::uses('ClassRegistry', 'Utility'); App::uses('Validation', 'Utility'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('Hash', 'Utility'); App::uses('BehaviorCollection', 'Model'); App::uses('ModelBehavior', 'Model'); @@ -1915,9 +1915,9 @@ class Model extends Object implements CakeEventListener { if (empty($this->data[$this->alias][$this->primaryKey]) && $this->_isUUIDField($this->primaryKey)) { if (array_key_exists($this->primaryKey, $this->data[$this->alias])) { $j = array_search($this->primaryKey, $fields); - $values[$j] = String::uuid(); + $values[$j] = CakeText::uuid(); } else { - list($fields[], $values[]) = array($this->primaryKey, String::uuid()); + list($fields[], $values[]) = array($this->primaryKey, CakeText::uuid()); } } @@ -2026,7 +2026,7 @@ class Model extends Object implements CakeEventListener { $values = array($id, $row); if ($isUUID && $primaryAdded) { - $values[] = String::uuid(); + $values[] = CakeText::uuid(); } $newValues[$row] = $values; @@ -3187,7 +3187,7 @@ class Model extends Object implements CakeEventListener { $list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null); } else { if (!is_array($query['fields'])) { - $query['fields'] = String::tokenize($query['fields']); + $query['fields'] = CakeText::tokenize($query['fields']); } if (count($query['fields']) === 1) { diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index ca7f8a97c..23b9f9cdc 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -17,7 +17,7 @@ App::uses('Multibyte', 'I18n'); App::uses('AbstractTransport', 'Network/Email'); App::uses('File', 'Utility'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('View', 'View'); /** @@ -776,7 +776,7 @@ class CakeEmail { } if ($this->_messageId !== false) { if ($this->_messageId === true) { - $headers['Message-ID'] = '<' . str_replace('-', '', String::UUID()) . '@' . $this->_domain . '>'; + $headers['Message-ID'] = '<' . str_replace('-', '', CakeText::UUID()) . '@' . $this->_domain . '>'; } else { $headers['Message-ID'] = $this->_messageId; } diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php index b106abb88..ee031bebb 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php @@ -20,7 +20,7 @@ App::uses('Model', 'Model'); App::uses('AppModel', 'Model'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); require_once dirname(dirname(__FILE__)) . DS . 'models.php'; @@ -73,7 +73,7 @@ class TreeBehaviorUuidTest extends CakeTestCase { 'conditions' => array($modelClass . '.name' => '1.1') )); - $id = String::uuid(); + $id = CakeText::uuid(); $this->Tree->create(); $result = $this->Tree->save(array($modelClass => array( 'id' => $id, diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index d35ea1ffc..69f0f8cea 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -19,7 +19,7 @@ */ App::uses('CakeLog', 'Log'); -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); /** * Provide custom logging and error handling. @@ -337,7 +337,7 @@ class Debugger { $trace['path'] = self::trimPath($trace['file']); $trace['reference'] = $reference; unset($trace['object'], $trace['args']); - $back[] = String::insert($tpl, $trace, array('before' => '{:', 'after' => '}')); + $back[] = CakeText::insert($tpl, $trace, array('before' => '{:', 'after' => '}')); } } @@ -637,7 +637,7 @@ class Debugger { * * `Debugger::addFormat('custom', $data);` * - * Where $data is an array of strings that use String::insert() variable + * Where $data is an array of strings that use CakeText::insert() variable * replacement. The template vars should be in a `{:id}` style. * An error formatter can have the following keys: * @@ -775,7 +775,7 @@ class Debugger { if (isset($tpl['links'])) { foreach ($tpl['links'] as $key => $val) { - $links[$key] = String::insert($val, $data, $insertOpts); + $links[$key] = CakeText::insert($val, $data, $insertOpts); } } @@ -791,14 +791,14 @@ class Debugger { if (is_array($value)) { $value = implode("\n", $value); } - $info .= String::insert($tpl[$key], array($key => $value) + $data, $insertOpts); + $info .= CakeText::insert($tpl[$key], array($key => $value) + $data, $insertOpts); } $links = implode(' ', $links); if (isset($tpl['callback']) && is_callable($tpl['callback'])) { return call_user_func($tpl['callback'], $data, compact('links', 'info')); } - echo String::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts); + echo CakeText::insert($tpl['error'], compact('links', 'info') + $data, $insertOpts); } /** diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index c46391263..7abe4515c 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -14,7 +14,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); /** * Library of array functions for manipulating and extracting data @@ -112,7 +112,7 @@ class Hash { if (strpos($path, '[') === false) { $tokens = explode('.', $path); } else { - $tokens = String::tokenize($path, '.', '[', ']'); + $tokens = CakeText::tokenize($path, '.', '[', ']'); } $_key = '__set_item__'; @@ -258,7 +258,7 @@ class Hash { if (strpos($path, '[') === false) { $tokens = explode('.', $path); } else { - $tokens = String::tokenize($path, '.', '[', ']'); + $tokens = CakeText::tokenize($path, '.', '[', ']'); } if (strpos($path, '{') === false && strpos($path, '[') === false) { @@ -341,7 +341,7 @@ class Hash { if (strpos($path, '[') === false) { $tokens = explode('.', $path); } else { - $tokens = String::tokenize($path, '.', '[', ']'); + $tokens = CakeText::tokenize($path, '.', '[', ']'); } if (strpos($path, '{') === false && strpos($path, '[') === false) { diff --git a/lib/Cake/Utility/Security.php b/lib/Cake/Utility/Security.php index c2d210664..51c43ace4 100644 --- a/lib/Cake/Utility/Security.php +++ b/lib/Cake/Utility/Security.php @@ -16,7 +16,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); /** * Security Library contains utility methods related to security @@ -63,7 +63,7 @@ class Security { * @return string Hash */ public static function generateAuthKey() { - return Security::hash(String::uuid()); + return Security::hash(CakeText::uuid()); } /** diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 5d05e0c8b..d52c8d7ad 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -16,7 +16,7 @@ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ -App::uses('String', 'Utility'); +App::uses('CakeText', 'Utility'); App::uses('Hash', 'Utility'); /** @@ -549,7 +549,7 @@ class Set { return null; } if (is_string($path) && strpos($path, '{') !== false) { - $path = String::tokenize($path, '.', '{', '}'); + $path = CakeText::tokenize($path, '.', '{', '}'); } elseif (is_string($path)) { $path = explode('.', $path); } diff --git a/lib/Cake/View/Helper/TextHelper.php b/lib/Cake/View/Helper/TextHelper.php index 05907c518..77d1595dc 100644 --- a/lib/Cake/View/Helper/TextHelper.php +++ b/lib/Cake/View/Helper/TextHelper.php @@ -225,7 +225,7 @@ class TextHelper extends AppHelper { * @param string $phrase The phrase that will be searched * @param array $options An array of html attributes and options. * @return string The highlighted text - * @see String::highlight() + * @see CakeText::highlight() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::highlight */ public function highlight($text, $phrase, $options = array()) { @@ -260,7 +260,7 @@ class TextHelper extends AppHelper { * * @param string $text Text * @return string The text without links - * @see String::stripLinks() + * @see CakeText::stripLinks() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::stripLinks */ public function stripLinks($text) { @@ -283,7 +283,7 @@ class TextHelper extends AppHelper { * @param int $length Length of returned string, including ellipsis. * @param array $options An array of html attributes and options. * @return string Trimmed string. - * @see String::truncate() + * @see CakeText::truncate() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::truncate */ public function truncate($text, $length = 100, $options = array()) { @@ -305,7 +305,7 @@ class TextHelper extends AppHelper { * @param int $length Length of returned string, including ellipsis. * @param array $options An array of html attributes and options. * @return string Trimmed string. - * @see String::tail() + * @see CakeText::tail() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::tail */ public function tail($text, $length = 100, $options = array()) { @@ -321,7 +321,7 @@ class TextHelper extends AppHelper { * @param int $radius The amount of characters that will be returned on each side of the founded phrase * @param string $ending Ending that will be appended * @return string Modified string - * @see String::excerpt() + * @see CakeText::excerpt() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::excerpt */ public function excerpt($text, $phrase, $radius = 100, $ending = '...') { @@ -335,7 +335,7 @@ class TextHelper extends AppHelper { * @param string $and The word used to join the last and second last items together with. Defaults to 'and'. * @param string $separator The separator used to join all the other items together. Defaults to ', '. * @return string The glued together string. - * @see String::toList() + * @see CakeText::toList() * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/text.html#TextHelper::toList */ public function toList($list, $and = null, $separator = ', ') {