mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Changing how merged rules are cleared so it doesn't generated notice errors in PHP4. Test added. Fixes #762
This commit is contained in:
parent
8d8fce4429
commit
7682c5896e
2 changed files with 19 additions and 21 deletions
|
@ -369,7 +369,10 @@ class Inflector {
|
||||||
} else {
|
} else {
|
||||||
$_this->{$var}[$rule] = array_merge($pattern, $_this->{$var}[$rule]);
|
$_this->{$var}[$rule] = array_merge($pattern, $_this->{$var}[$rule]);
|
||||||
}
|
}
|
||||||
unset($rules[$rule], $_this->{$var}['cache' . ucfirst($rule)], $_this->{$var}['merged'][$rule]);
|
unset($rules[$rule], $_this->{$var}['cache' . ucfirst($rule)]);
|
||||||
|
if (isset($_this->{$var}['merged'][$rule])) {
|
||||||
|
unset($_this->{$var}['merged'][$rule]);
|
||||||
|
}
|
||||||
if ($type === 'plural') {
|
if ($type === 'plural') {
|
||||||
$_this->_pluralized = $_this->_tableize = array();
|
$_this->_pluralized = $_this->_tableize = array();
|
||||||
} elseif ($type === 'singular') {
|
} elseif ($type === 'singular') {
|
||||||
|
|
|
@ -42,16 +42,6 @@ class InflectorTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
var $Inflector = null;
|
var $Inflector = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* setUp method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function setUp() {
|
|
||||||
$this->Inflector = Inflector::getInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testInstantiation method
|
* testInstantiation method
|
||||||
*
|
*
|
||||||
|
@ -59,7 +49,8 @@ class InflectorTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testInstantiation() {
|
function testInstantiation() {
|
||||||
$this->assertEqual(Inflector::getInstance(), $this->Inflector);
|
$Inflector =& Inflector::getInstance();
|
||||||
|
$this->assertEqual(Inflector::getInstance(), $Inflector);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -339,6 +330,19 @@ class InflectorTest extends CakeTestCase {
|
||||||
$this->assertEqual(Inflector::humanize('file_systems'), 'File Systems');
|
$this->assertEqual(Inflector::humanize('file_systems'), 'File Systems');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This test if run in isolation should not cause errors in PHP4.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testRulesNoErrorPHP4() {
|
||||||
|
Inflector::rules('plural', array(
|
||||||
|
'rules' => array(),
|
||||||
|
'irregular' => array(),
|
||||||
|
'uninflected' => array('pays')
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testCustomPluralRule method
|
* testCustomPluralRule method
|
||||||
*
|
*
|
||||||
|
@ -455,13 +459,4 @@ class InflectorTest extends CakeTestCase {
|
||||||
$this->assertEqual(Inflector::singularize('Atlas'), 'Atlas');
|
$this->assertEqual(Inflector::singularize('Atlas'), 'Atlas');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* tearDown method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function tearDown() {
|
|
||||||
unset($this->Inflector);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue