Skip to content

Commit

Permalink
fixes agriya#1 : String class has changed to CakeText class.
Browse files Browse the repository at this point in the history
  • Loading branch information
vibbulan committed Jun 24, 2019
1 parent b67860c commit 844a3bc
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion core/lib/Cake/Console/Command/Task/FixtureTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ protected function _generateRecords($tableInfo, $recordCount = 1) {
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'])) {
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Cake/Console/Command/Task/ProjectTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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');

/**
Expand Down Expand Up @@ -207,7 +207,7 @@ public function bake($path, $skel = null, $skip = array('empty')) {
}

foreach ($Folder->messages() as $message) {
$this->out(String::wrap(' * ' . $message), 1, Shell::VERBOSE);
$this->out(CakeText::wrap(' * ' . $message), 1, Shell::VERBOSE);
}

return true;
Expand Down
12 changes: 6 additions & 6 deletions core/lib/Cake/Console/HelpFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @link http://cakephp.org CakePHP(tm) Project
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');

/**
* HelpFormatter formats help for console shells. Can format to either
Expand Down Expand Up @@ -64,7 +64,7 @@ public function text($width = 72) {
$out = array();
$description = $parser->description();
if (!empty($description)) {
$out[] = String::wrap($description, $width);
$out[] = CakeText::wrap($description, $width);
$out[] = '';
}
$out[] = __d('cake_console', '<info>Usage:</info>');
Expand All @@ -76,7 +76,7 @@ public function text($width = 72) {
$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
Expand All @@ -93,7 +93,7 @@ public function text($width = 72) {
$out[] = __d('cake_console', '<info>Options:</info>');
$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
Expand All @@ -108,7 +108,7 @@ public function text($width = 72) {
$out[] = __d('cake_console', '<info>Arguments:</info>');
$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
Expand All @@ -118,7 +118,7 @@ public function text($width = 72) {
}
$epilog = $parser->epilog();
if (!empty($epilog)) {
$out[] = String::wrap($epilog, $width);
$out[] = CakeText::wrap($epilog, $width);
$out[] = '';
}
return implode("\n", $out);
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Cake/Console/Shell.php
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,11 @@ protected function _getInput($prompt, $options, $default) {
* @param string $text Text the text to format.
* @param string|integer|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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Cake/Controller/Component/SecurityComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

App::uses('Component', 'Controller');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
App::uses('Hash', 'Utility');
App::uses('Security', 'Utility');

Expand Down
2 changes: 1 addition & 1 deletion core/lib/Cake/Error/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class ErrorHandler {
* @return void
* @see http://php.net/manual/en/function.set-exception-handler.php
*/
public static function handleException(Exception $exception) {
public static function handleException($exception) {
$config = Configure::read('Exception');
if (!empty($config['log'])) {
$message = sprintf("[%s] %s\n%s",
Expand Down
2 changes: 1 addition & 1 deletion core/lib/Cake/Error/ExceptionRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ExceptionRenderer {
*
* @param Exception $exception Exception
*/
public function __construct(Exception $exception) {
public function __construct($exception) {
$this->controller = $this->_getController($exception);

if (method_exists($this->controller, 'apperror')) {
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Cake/Model/Datasource/Database/Sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

App::uses('DboSource', 'Model/Datasource');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');

/**
* DBO implementation for the SQLite3 DBMS.
Expand Down Expand Up @@ -283,7 +283,7 @@ public function resultSet($results) {
$last = strripos($querystring, 'FROM');
if ($last !== false) {
$selectpart = substr($querystring, 7, $last - 8);
$selects = String::tokenize($selectpart, ',', '(', ')');
$selects = CakeText::tokenize($selectpart, ',', '(', ')');
}
} elseif (strpos($querystring, 'PRAGMA table_info') === 0) {
$selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk');
Expand Down
6 changes: 3 additions & 3 deletions core/lib/Cake/Model/Datasource/DboSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

App::uses('DataSource', 'Model/Datasource');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
App::uses('View', 'View');

/**
Expand Down Expand Up @@ -2303,7 +2303,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote =
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);
Expand Down Expand Up @@ -2589,7 +2589,7 @@ protected function _parseKey($model, $key, $value) {
}

if ($bound) {
return String::insert($key . ' ' . trim($operator), $value);
return CakeText::insert($key . ' ' . trim($operator), $value);
}

if (!preg_match($operatorMatch, trim($operator))) {
Expand Down
10 changes: 5 additions & 5 deletions core/lib/Cake/Model/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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');
Expand Down Expand Up @@ -1748,9 +1748,9 @@ public function save($data = null, $validate = true, $fieldList = array()) {
if (empty($this->data[$this->alias][$this->primaryKey]) && $isUUID) {
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());
}
}

Expand Down Expand Up @@ -1842,7 +1842,7 @@ protected function _saveMulti($joined, $id, $db) {
$newJoins[] = $row;
$values = array($id, $row);
if ($isUUID && $primaryAdded) {
$values[] = String::uuid();
$values[] = CakeText::uuid();
}
$newValues[$row] = $values;
unset($values);
Expand Down Expand Up @@ -2909,7 +2909,7 @@ protected function _findList($state, $query, $results = array()) {
$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) {
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Cake/Network/Email/CakeEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
App::uses('Validation', 'Utility');
App::uses('Multibyte', 'I18n');
App::uses('AbstractTransport', 'Network/Email');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');
App::uses('View', 'View');
App::import('I18n', 'Multibyte');

Expand Down Expand Up @@ -711,7 +711,7 @@ public function getHeaders($include = array()) {
}
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @package Cake.Utility
*/
class String {
class CakeText {

/**
* Generate a random UUID
Expand Down Expand Up @@ -181,7 +181,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ
/**
* Replaces variable placeholders inside a $str with any given $data. Each key in the $data array
* corresponds to a variable placeholder name in $str.
* Example: `String::insert(':name is :age years old.', array('name' => 'Bob', '65'));`
* Example: `CakeText::insert(':name is :age years old.', array('name' => 'Bob', '65'));`
* Returns: Bob is 65 years old.
*
* Available $options are:
Expand All @@ -191,7 +191,7 @@ public static function tokenize($data, $separator = ',', $leftBound = '(', $righ
* - escape: The character or string used to escape the before character / string (Defaults to `\`)
* - format: A regex to use for matching variable placeholders. Default is: `/(?<!\\)\:%s/`
* (Overwrites before, after, breaks escape / clean)
* - clean: A boolean or array with instructions for String::cleanInsert
* - clean: A boolean or array with instructions for CakeText::cleanInsert
*
* @param string $str A string containing variable placeholders
* @param string $data A key => val array where each key stands for a placeholder variable name
Expand All @@ -207,7 +207,7 @@ public static function insert($str, $data, $options = array()) {
$format = $options['format'];
$data = (array)$data;
if (empty($data)) {
return ($options['clean']) ? String::cleanInsert($str, $options) : $str;
return ($options['clean']) ? CakeText::cleanInsert($str, $options) : $str;
}

if (!isset($format)) {
Expand All @@ -226,7 +226,7 @@ public static function insert($str, $data, $options = array()) {
$offset = $pos + strlen($val);
$str = substr_replace($str, $val, $pos, 1);
}
return ($options['clean']) ? String::cleanInsert($str, $options) : $str;
return ($options['clean']) ? CakeText::cleanInsert($str, $options) : $str;
} else {
asort($data);

Expand All @@ -251,19 +251,19 @@ public static function insert($str, $data, $options = array()) {
if (!isset($options['format']) && isset($options['before'])) {
$str = str_replace($options['escape'] . $options['before'], $options['before'], $str);
}
return ($options['clean']) ? String::cleanInsert($str, $options) : $str;
return ($options['clean']) ? CakeText::cleanInsert($str, $options) : $str;
}

/**
* Cleans up a String::insert() formatted string with given $options depending on the 'clean' key in
* Cleans up a CakeText::insert() formatted string with given $options depending on the 'clean' key in
* $options. The default method used is text but html is also available. The goal of this function
* is to replace all whitespace and unneeded markup around placeholders that did not get replaced
* by String::insert().
* by CakeText::insert().
*
* @param string $str
* @param string $options
* @return string
* @see String::insert()
* @see CakeText::insert()
*/
public static function cleanInsert($str, $options) {
$clean = $options['clean'];
Expand Down Expand Up @@ -292,7 +292,7 @@ public static function cleanInsert($str, $options) {
$str = preg_replace($kleenex, $clean['replacement'], $str);
if ($clean['andText']) {
$options['clean'] = array('method' => 'text');
$str = String::cleanInsert($str, $options);
$str = CakeText::cleanInsert($str, $options);
}
break;
case 'text':
Expand Down
12 changes: 6 additions & 6 deletions core/lib/Cake/Utility/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

App::uses('CakeLog', 'Log');
App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');

/**
* Provide custom logging and error handling.
Expand Down Expand Up @@ -340,7 +340,7 @@ public static function trace($options = array()) {
$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' => '}'));
}
}

Expand Down Expand Up @@ -606,7 +606,7 @@ public static function outputAs($format = null) {
*
* `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:
*
Expand Down Expand Up @@ -738,7 +738,7 @@ public function outputError($data) {

if (isset($tpl['links'])) {
foreach ($tpl['links'] as $key => $val) {
$links[$key] = String::insert($val, $data, $insertOpts);
$links[$key] = CakeText::insert($val, $data, $insertOpts);
}
}

Expand All @@ -754,14 +754,14 @@ public function outputError($data) {
if (is_array($value)) {
$value = join("\n", $value);
}
$info .= String::insert($tpl[$key], array($key => $value) + $data, $insertOpts);
$info .= CakeText::insert($tpl[$key], array($key => $value) + $data, $insertOpts);
}
$links = join(' ', $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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Cake/Utility/Hash.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');

/**
* Library of array functions for manipulating and extracting data
Expand Down Expand Up @@ -99,7 +99,7 @@ public static function extract(array $data, $path) {
if (strpos('[', $path) === false) {
$tokens = explode('.', $path);
} else {
$tokens = String::tokenize($path, '.', '[', ']');
$tokens = CakeText::tokenize($path, '.', '[', ']');
}

$_key = '__set_item__';
Expand Down
4 changes: 2 additions & 2 deletions core/lib/Cake/Utility/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::uses('String', 'Utility');
App::uses('CakeText', 'Utility');

/**
* Security Library contains utility methods related to security
Expand Down Expand Up @@ -59,7 +59,7 @@ public static function inactiveMins() {
* @return string Hash
*/
public static function generateAuthKey() {
return Security::hash(String::uuid());
return Security::hash(CakeText::uuid());
}

/**
Expand Down
Loading

0 comments on commit 844a3bc

Please sign in to comment.