mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Additional inflection rules provided through Inflector::rules() now take precedence over the core ones as expected. Fixes #2016
This commit is contained in:
parent
0267a048f3
commit
07f6803540
2 changed files with 10 additions and 4 deletions
|
@ -369,7 +369,11 @@ class Inflector {
|
|||
if ($reset) {
|
||||
$_this->{$var}[$rule] = $pattern;
|
||||
} else {
|
||||
$_this->{$var}[$rule] = array_merge($pattern, $_this->{$var}[$rule]);
|
||||
if ($rule === 'uninflected') {
|
||||
$_this->{$var}[$rule] = array_merge($pattern, $_this->{$var}[$rule]);
|
||||
} else {
|
||||
$_this->{$var}[$rule] = $pattern + $_this->{$var}[$rule];
|
||||
}
|
||||
}
|
||||
unset($rules[$rule], $_this->{$var}['cache' . ucfirst($rule)]);
|
||||
if (isset($_this->{$var}['merged'][$rule])) {
|
||||
|
@ -382,7 +386,7 @@ class Inflector {
|
|||
}
|
||||
}
|
||||
}
|
||||
$_this->{$var}['rules'] = array_merge($rules, $_this->{$var}['rules']);
|
||||
$_this->{$var}['rules'] = $rules + $_this->{$var}['rules'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -434,9 +434,11 @@ class InflectorTest extends CakeTestCase {
|
|||
$this->assertEqual(Inflector::singularize('Bananas'), 'Banazzz', 'Was inflected with old rules. %s');
|
||||
|
||||
Inflector::rules('plural', array(
|
||||
'rules' => array('/(.*)na$/i' => '\1zzz')
|
||||
'rules' => array('/(.*)na$/i' => '\1zzz'),
|
||||
'irregular' => array('corpus' => 'corpora')
|
||||
));
|
||||
$this->assertEqual(Inflector::pluralize('Banana'), 'Banazzz', 'Was inflected with old rules. %s');
|
||||
$this->assertEqual(Inflector::pluralize('Banana'), 'Banazzz', 'Was inflected with old rules: %s');
|
||||
$this->assertEqual(Inflector::pluralize('corpus'), 'corpora', 'Was inflected with old irregular form: %s');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue