case-insensitivity is pointless

This commit is contained in:
Joby Elliott 2018-09-14 10:39:12 -06:00
parent 0d3c017d20
commit e143f2b284
2 changed files with 5 additions and 11 deletions

View file

@ -151,7 +151,7 @@ trait FlatArrayTrait
{ {
//normalize key names in $value, and also $name //normalize key names in $value, and also $name
$value = $this->normalizeValue($value); $value = $this->normalizeValue($value);
$name = strtolower($name); $name = $name;
//check for home strings //check for home strings
if ($name == '' || $name === null) { if ($name == '' || $name === null) {
if ($unset) { if ($unset) {
@ -210,7 +210,7 @@ trait FlatArrayTrait
} }
$norm = []; $norm = [];
foreach ($value as $key => $value) { foreach ($value as $key => $value) {
$nKey = preg_replace('/\./', '', strtolower($key)); $nKey = preg_replace('/\./', '', $key);
if ($nKey == '') { if ($nKey == '') {
throw new \Exception("Key \"$key\" can't be used inside a FlatArray"); throw new \Exception("Key \"$key\" can't be used inside a FlatArray");
} }

View file

@ -89,19 +89,13 @@ class FlatArrayTest extends TestCase
); );
} }
public function testCaseNormalizing() public function testCaseSensitivity()
{ {
$h = new FlatArray([ $h = new FlatArray([
'ABC'=>['ABC'=>'ABC'] 'ABC'=>['ABC'=>'ABC']
]); ]);
$this->assertEquals('ABC', $h['abc.abc']); $this->assertNull($h['abc.abc']);
$this->assertEquals('ABC', $h['Abc.aBC']); $this->assertNull($h['Abc.aBC']);
$h['Abc.aBC'] = 'abc';
$this->assertEquals('abc', $h['abc.abc']);
$this->assertEquals('abc', $h['Abc.aBC']);
$h['ABC'] = ['ABC'=>'ABC'];
$this->assertEquals('ABC', $h['abc.abc']);
$this->assertEquals('ABC', $h['Abc.aBC']);
} }
public function testAccidentalSubstrings() public function testAccidentalSubstrings()