mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Updating docblocks and adding @link tags.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7816 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
0fd3badee4
commit
5a0ab7b220
1 changed files with 27 additions and 14 deletions
|
@ -43,34 +43,37 @@ if (!class_exists('Set')) {
|
||||||
*
|
*
|
||||||
* @package cake
|
* @package cake
|
||||||
* @subpackage cake.cake.libs
|
* @subpackage cake.cake.libs
|
||||||
|
* @link http://book.cakephp.org/view/491/Inflector
|
||||||
*/
|
*/
|
||||||
class Inflector extends Object {
|
class Inflector extends Object {
|
||||||
/**
|
/**
|
||||||
* Pluralized words
|
* Pluralized words.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
**/
|
**/
|
||||||
var $pluralized = array();
|
var $pluralized = array();
|
||||||
/**
|
/**
|
||||||
* All plural rules
|
* List of pluralization rules in the form of pattern => replacement.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
|
* @link http://book.cakephp.org/view/47/Custom-Inflections
|
||||||
**/
|
**/
|
||||||
var $pluralRules = array();
|
var $pluralRules = array();
|
||||||
/**
|
/**
|
||||||
* Singularized words
|
* Singularized words.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access private
|
* @access private
|
||||||
**/
|
**/
|
||||||
var $singularized = array();
|
var $singularized = array();
|
||||||
/**
|
/**
|
||||||
* All singular rules
|
* List of singularization rules in the form of pattern => replacement.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @access public
|
* @access public
|
||||||
|
* @link http://book.cakephp.org/view/47/Custom-Inflections
|
||||||
**/
|
**/
|
||||||
var $singularRules = array();
|
var $singularRules = array();
|
||||||
/**
|
/**
|
||||||
|
@ -140,7 +143,7 @@ class Inflector extends Object {
|
||||||
return $instance[0];
|
return $instance[0];
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Initializes plural inflection rules
|
* Initializes plural inflection rules.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -228,6 +231,7 @@ class Inflector extends Object {
|
||||||
* @return string Word in plural
|
* @return string Word in plural
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
|
* @link http://book.cakephp.org/view/572/Class-methods
|
||||||
*/
|
*/
|
||||||
function pluralize($word) {
|
function pluralize($word) {
|
||||||
$_this =& Inflector::getInstance();
|
$_this =& Inflector::getInstance();
|
||||||
|
@ -267,7 +271,7 @@ class Inflector extends Object {
|
||||||
return $word;
|
return $word;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Initializes singular inflection rules
|
* Initializes singular inflection rules.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @access protected
|
* @access protected
|
||||||
|
@ -364,6 +368,7 @@ class Inflector extends Object {
|
||||||
* @return string Word in singular
|
* @return string Word in singular
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
|
* @link http://book.cakephp.org/view/572/Class-methods
|
||||||
*/
|
*/
|
||||||
function singularize($word) {
|
function singularize($word) {
|
||||||
$_this =& Inflector::getInstance();
|
$_this =& Inflector::getInstance();
|
||||||
|
@ -403,73 +408,79 @@ class Inflector extends Object {
|
||||||
return $word;
|
return $word;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns given $lower_case_and_underscored_word as a CamelCased word.
|
* Returns the given lower_case_and_underscored_word as a CamelCased word.
|
||||||
*
|
*
|
||||||
* @param string $lower_case_and_underscored_word Word to camelize
|
* @param string $lower_case_and_underscored_word Word to camelize
|
||||||
* @return string Camelized word. LikeThis.
|
* @return string Camelized word. LikeThis.
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
|
* @link http://book.cakephp.org/view/572/Class-methods
|
||||||
*/
|
*/
|
||||||
function camelize($lowerCaseAndUnderscoredWord) {
|
function camelize($lowerCaseAndUnderscoredWord) {
|
||||||
$replace = str_replace(" ", "", ucwords(str_replace("_", " ", $lowerCaseAndUnderscoredWord)));
|
$replace = str_replace(" ", "", ucwords(str_replace("_", " ", $lowerCaseAndUnderscoredWord)));
|
||||||
return $replace;
|
return $replace;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns an underscore-syntaxed (like_this_dear_reader) version of the $camel_cased_word.
|
* Returns the given camelCasedWord as an underscored_word.
|
||||||
*
|
*
|
||||||
* @param string $camelCasedWord Camel-cased word to be "underscorized"
|
* @param string $camelCasedWord Camel-cased word to be "underscorized"
|
||||||
* @return string Underscore-syntaxed version of the $camelCasedWord
|
* @return string Underscore-syntaxed version of the $camelCasedWord
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
|
* @link http://book.cakephp.org/view/572/Class-methods
|
||||||
*/
|
*/
|
||||||
function underscore($camelCasedWord) {
|
function underscore($camelCasedWord) {
|
||||||
$replace = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord));
|
$replace = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $camelCasedWord));
|
||||||
return $replace;
|
return $replace;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns a human-readable string from $lower_case_and_underscored_word,
|
* Returns the given underscored_word_group as a Human Readable Word Group.
|
||||||
* by replacing underscores with a space, and by upper-casing the initial characters.
|
* (Underscores are replaced by spaces and capitalized following words.)
|
||||||
*
|
*
|
||||||
* @param string $lower_case_and_underscored_word String to be made more readable
|
* @param string $lower_case_and_underscored_word String to be made more readable
|
||||||
* @return string Human-readable string
|
* @return string Human-readable string
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
|
* @link http://book.cakephp.org/view/572/Class-methods
|
||||||
*/
|
*/
|
||||||
function humanize($lowerCaseAndUnderscoredWord) {
|
function humanize($lowerCaseAndUnderscoredWord) {
|
||||||
$replace = ucwords(str_replace("_", " ", $lowerCaseAndUnderscoredWord));
|
$replace = ucwords(str_replace("_", " ", $lowerCaseAndUnderscoredWord));
|
||||||
return $replace;
|
return $replace;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns corresponding table name for given $className. ("posts" for the model class "Post").
|
* Returns corresponding table name for given model $className. ("people" for the model class "Person").
|
||||||
*
|
*
|
||||||
* @param string $className Name of class to get database table name for
|
* @param string $className Name of class to get database table name for
|
||||||
* @return string Name of the database table for given class
|
* @return string Name of the database table for given class
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
|
* @link http://book.cakephp.org/view/572/Class-methods
|
||||||
*/
|
*/
|
||||||
function tableize($className) {
|
function tableize($className) {
|
||||||
$replace = Inflector::pluralize(Inflector::underscore($className));
|
$replace = Inflector::pluralize(Inflector::underscore($className));
|
||||||
return $replace;
|
return $replace;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns Cake model class name ("Post" for the database table "posts".) for given database table.
|
* Returns Cake model class name ("Person" for the database table "people".) for given database table.
|
||||||
*
|
*
|
||||||
* @param string $tableName Name of database table to get class name for
|
* @param string $tableName Name of database table to get class name for
|
||||||
* @return string Class name
|
* @return string Class name
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
|
* @link http://book.cakephp.org/view/572/Class-methods
|
||||||
*/
|
*/
|
||||||
function classify($tableName) {
|
function classify($tableName) {
|
||||||
$replace = Inflector::camelize(Inflector::singularize($tableName));
|
$replace = Inflector::camelize(Inflector::singularize($tableName));
|
||||||
return $replace;
|
return $replace;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns camelBacked version of a string.
|
* Returns camelBacked version of an underscored string.
|
||||||
*
|
*
|
||||||
* @param string $string
|
* @param string $string
|
||||||
* @return string in variable form
|
* @return string in variable form
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
|
* @link http://book.cakephp.org/view/572/Class-methods
|
||||||
*/
|
*/
|
||||||
function variable($string) {
|
function variable($string) {
|
||||||
$string = Inflector::camelize(Inflector::underscore($string));
|
$string = Inflector::camelize(Inflector::underscore($string));
|
||||||
|
@ -478,13 +489,15 @@ class Inflector extends Object {
|
||||||
return $variable;
|
return $variable;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns a string with all spaces converted to $replacement and non word characters removed.
|
* Returns a string with all spaces converted to underscores (by default), accented
|
||||||
|
* characters converted to non-accented characters, and non word characters removed.
|
||||||
*
|
*
|
||||||
* @param string $string
|
* @param string $string
|
||||||
* @param string $replacement
|
* @param string $replacement
|
||||||
* @return string
|
* @return string
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
|
* @link http://book.cakephp.org/view/572/Class-methods
|
||||||
*/
|
*/
|
||||||
function slug($string, $replacement = '_') {
|
function slug($string, $replacement = '_') {
|
||||||
if (!class_exists('String')) {
|
if (!class_exists('String')) {
|
||||||
|
|
Loading…
Reference in a new issue