Skip to content

Commit

Permalink
Renaming inflector regex cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
jperras committed Mar 18, 2009
1 parent 7bc9489 commit b563393
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions cake/libs/inflector.php
Expand Up @@ -216,7 +216,7 @@ function rules($type, $rules = array()) {
foreach ($rules as $rule => $pattern) {
if (is_array($pattern)) {
$_this->{$type}[$rule] = array_merge($pattern, $_this->{$type}[$rule]);
unset($rules[$rule], $_this->{$type}['regex' . ucfirst($rule)]);
unset($rules[$rule], $_this->{$type}['cache' . ucfirst($rule)]);
}
}
$_this->{$type}['rules'] = array_merge($rules, $_this->{$type}['rules']);
Expand All @@ -239,17 +239,17 @@ function pluralize($word) {
extract($_this->plural);
$uninflected = array_merge($uninflected, $_this->uninflected);

if (!isset($_this->plural['regexUninflected']) || !isset($_this->plural['regexIrregular'])) {
$_this->plural['regexUninflected'] = '(?:' . join( '|', $uninflected) . ')';
$_this->plural['regexIrregular'] = '(?:' . join( '|', array_keys($irregular)) . ')';
if (!isset($_this->plural['cacheUninflected']) || !isset($_this->plural['cacheIrregular'])) {
$_this->plural['cacheUninflected'] = '(?:' . join( '|', $uninflected) . ')';
$_this->plural['cacheIrregular'] = '(?:' . join( '|', array_keys($irregular)) . ')';
}

if (preg_match('/(.+?)\\b(' . $_this->plural['regexIrregular'] . ')$/i', $word, $regs)) {
if (preg_match('/(.+?)\\b(' . $_this->plural['cacheIrregular'] . ')$/i', $word, $regs)) {
$_this->pluralized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
return $_this->pluralized[$word];
}

if (preg_match('/^(' . $_this->plural['regexUninflected'] . ')$/i', $word, $regs)) {
if (preg_match('/^(' . $_this->plural['cacheUninflected'] . ')$/i', $word, $regs)) {
$_this->pluralized[$word] = $word;
return $word;
}
Expand Down Expand Up @@ -282,17 +282,17 @@ function singularize($word) {
$uninflected = array_merge($uninflected, $_this->uninflected);
$irregular = array_flip($_this->plural['irregular']);

if (!isset($_this->singular['regexUninflected']) || !isset($_this->singular['regexIrregular'])) {
$_this->singular['regexUninflected'] = '(?:' . join( '|', $uninflected) . ')';
$_this->singular['regexIrregular'] = '(?:' . join( '|', array_keys($irregular)) . ')';
if (!isset($_this->singular['cacheUninflected']) || !isset($_this->singular['cacheIrregular'])) {
$_this->singular['cacheUninflected'] = '(?:' . join( '|', $uninflected) . ')';
$_this->singular['cacheIrregular'] = '(?:' . join( '|', array_keys($irregular)) . ')';
}

if (preg_match('/(.+?)\\b(' . $_this->singular['regexUninflected'] . ')$/i', $word, $regs)) {
if (preg_match('/(.+?)\\b(' . $_this->singular['cacheUninflected'] . ')$/i', $word, $regs)) {
$_this->singularized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
return $_this->singularized[$word];
}

if (preg_match('/^(' . $_this->singular['regexUninflected'] . ')$/i', $word, $regs)) {
if (preg_match('/^(' . $_this->singular['cacheUninflected'] . ')$/i', $word, $regs)) {
$_this->singularized[$word] = $word;
return $word;
}
Expand Down

0 comments on commit b563393

Please sign in to comment.