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
vibbulan committed Jun 24, 2019
1 parent b67860c commit 844a3bc
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
@@ -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'])) {
4 changes: 2 additions & 2 deletions core/lib/Cake/Console/Command/Task/ProjectTask.php
Original file line number Diff line number Diff line change
@@ -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');

/**
@@ -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;
12 changes: 6 additions & 6 deletions core/lib/Cake/Console/HelpFormatter.php
Original file line number Diff line number Diff line change
@@ -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
@@ -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>');
@@ -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
@@ -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
@@ -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
@@ -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);
4 changes: 2 additions & 2 deletions core/lib/Cake/Console/Shell.php
Original file line number Diff line number Diff line change
@@ -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);
}

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

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

2 changes: 1 addition & 1 deletion core/lib/Cake/Error/ErrorHandler.php
Original file line number Diff line number Diff line change
@@ -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",
2 changes: 1 addition & 1 deletion core/lib/Cake/Error/ExceptionRenderer.php
Original file line number Diff line number Diff line change
@@ -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')) {
4 changes: 2 additions & 2 deletions core/lib/Cake/Model/Datasource/Database/Sqlite.php
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
*/

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

/**
* DBO implementation for the SQLite3 DBMS.
@@ -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');
6 changes: 3 additions & 3 deletions core/lib/Cake/Model/Datasource/DboSource.php
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
*/

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

/**
@@ -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);
@@ -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))) {
10 changes: 5 additions & 5 deletions core/lib/Cake/Model/Model.php
Original file line number Diff line number Diff line change
@@ -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');
@@ -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());
}
}

@@ -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);
@@ -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) {
4 changes: 2 additions & 2 deletions core/lib/Cake/Network/Email/CakeEmail.php
Original file line number Diff line number Diff line change
@@ -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');

@@ -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;
}
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@
*
* @package Cake.Utility
*/
class String {
class CakeText {

/**
* Generate a random UUID
@@ -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:
@@ -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
@@ -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)) {
@@ -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);

@@ -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'];
@@ -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':
12 changes: 6 additions & 6 deletions core/lib/Cake/Utility/Debugger.php
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
*/

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

/**
* Provide custom logging and error handling.
@@ -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' => '}'));
}
}

@@ -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:
*
@@ -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);
}
}

@@ -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);
}

/**
4 changes: 2 additions & 2 deletions core/lib/Cake/Utility/Hash.php
Original file line number Diff line number Diff line change
@@ -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
@@ -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__';
4 changes: 2 additions & 2 deletions core/lib/Cake/Utility/Security.php
Original file line number Diff line number Diff line change
@@ -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
@@ -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());
}

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

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

/**
@@ -549,7 +549,7 @@ public static function classicExtract($data, $path = null) {
return null;
}
if (is_string($path) && strpos($path, '{') !== false) {
$path = String::tokenize($path, '.', '{', '}');
$path = CakeText::tokenize($path, '.', '{', '}');
} elseif (is_string($path)) {
$path = explode('.', $path);
}
12 changes: 6 additions & 6 deletions core/lib/Cake/View/Helper/TextHelper.php
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ class TextHelper extends AppHelper {
* @throws CakeException when the engine class could not be found.
*/
public function __construct(View $View, $settings = array()) {
$settings = Hash::merge(array('engine' => 'String'), $settings);
$settings = Hash::merge(array('engine' => 'CakeText'), $settings);
parent::__construct($View, $settings);
list($plugin, $engineClass) = pluginSplit($settings['engine'], true);
App::uses($engineClass, $plugin . 'Utility');
@@ -211,7 +211,7 @@ public function autoLink($text, $options = array()) {
}

/**
* @see String::highlight()
* @see CakeText::highlight()
*
* @param string $text Text to search the phrase in
* @param string $phrase The phrase that will be searched
@@ -224,7 +224,7 @@ public function highlight($text, $phrase, $options = array()) {
}

/**
* @see String::stripLinks()
* @see CakeText::stripLinks()
*
* @param string $text Text
* @return string The text without links
@@ -235,7 +235,7 @@ public function stripLinks($text) {
}

/**
* @see String::truncate()
* @see CakeText::truncate()
*
* @param string $text String to truncate.
* @param integer $length Length of returned string, including ellipsis.
@@ -248,7 +248,7 @@ public function truncate($text, $length = 100, $options = array(), $ending = '..
}

/**
* @see String::excerpt()
* @see CakeText::excerpt()
*
* @param string $text String to search the phrase in
* @param string $phrase Phrase that will be searched for
@@ -262,7 +262,7 @@ public function excerpt($text, $phrase, $radius = 100, $ending = '...') {
}

/**
* @see String::toList()
* @see CakeText::toList()
*
* @param array $list The list to be joined
* @param string $and The word used to join the last and second last items together with. Defaults to 'and'
16 changes: 8 additions & 8 deletions core/plugins/DebugKit/Console/Command/BenchmarkShell.php
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@
* @todo Export/graphing of data to .dot format for graphviz visualization
* @todo Make calculated results round to leading significant digit position of std dev.
*/
App::uses('String','Utility');
App::uses('CakeText','Utility');

class BenchmarkShell extends Shell {
/**
@@ -48,7 +48,7 @@ public function main() {
$options = array_merge($defaults, $this->params);
$times = array();

$this->out(String::insert(__d('debug_kit', '-> Testing :url'), compact('url')));
$this->out(CakeText::insert(__d('debug_kit', '-> Testing :url'), compact('url')));
$this->out("");
for ($i = 0; $i < $options['n']; $i++) {
if (floor($options['t'] - array_sum($times)) <= 0 || $options['n'] <= 1) {
@@ -73,24 +73,24 @@ protected function _results($times) {
$duration = array_sum($times);
$requests = count($times);

$this->out(String::insert(__d('debug_kit', 'Total Requests made: :requests'), compact('requests')));
$this->out(String::insert(__d('debug_kit', 'Total Time elapsed: :duration (seconds)'), compact('duration')));
$this->out(CakeText::insert(__d('debug_kit', 'Total Requests made: :requests'), compact('requests')));
$this->out(CakeText::insert(__d('debug_kit', 'Total Time elapsed: :duration (seconds)'), compact('duration')));

$this->out("");

$this->out(String::insert(__d('debug_kit', 'Requests/Second: :rps req/sec'), array(
$this->out(CakeText::insert(__d('debug_kit', 'Requests/Second: :rps req/sec'), array(
'rps' => round($requests / $duration, 3)
)));

$this->out(String::insert(__d('debug_kit', 'Average request time: :average-time seconds'), array(
$this->out(CakeText::insert(__d('debug_kit', 'Average request time: :average-time seconds'), array(
'average-time' => round($duration / $requests, 3)
)));

$this->out(String::insert(__d('debug_kit', 'Standard deviation of average request time: :std-dev'), array(
$this->out(CakeText::insert(__d('debug_kit', 'Standard deviation of average request time: :std-dev'), array(
'std-dev' => round($this->_deviation($times, true), 3)
)));

$this->out(String::insert(__d('debug_kit', 'Longest/shortest request: :longest sec/:shortest sec'), array(
$this->out(CakeText::insert(__d('debug_kit', 'Longest/shortest request: :longest sec/:shortest sec'), array(
'longest' => round(max($times), 3),
'shortest' => round(min($times), 3)
)));

0 comments on commit 844a3bc

Please sign in to comment.