Commit b62a9ed8 authored by yosymfony's avatar yosymfony
Browse files

The method addArrayOfTableKeyToWorkArray checks if the key part was declared as a table

parent e22bc2fa
......@@ -24,6 +24,7 @@ use Yosymfony\ParserUtils\SyntaxErrorException;
class Parser extends AbstractParser
{
private $keys = [];
private $keyOfTables = [];
private $keysOfImplicitArrayOfTables = [];
private $arrayOfTablekeyCounters = [];
private $currentKeyPrefix = '';
......@@ -472,7 +473,7 @@ class Parser extends AbstractParser
$this->addArrayKeyToWorkArray($key);
}
$this->addKeyToKeyStore($this->composeKeyWithCurrentKeyPrefix($fullTableName));
$this->addKeyToTableKeyStore($this->composeKeyWithCurrentKeyPrefix($fullTableName));
$this->currentKeyPrefix = $fullTableName;
$this->matchNext('T_RIGHT_SQUARE_BRAKET', $ts);
......@@ -556,6 +557,11 @@ class Parser extends AbstractParser
$this->keys[] = $keyName;
}
private function addKeyToTableKeyStore(string $keyName) : void
{
$this->addKeyToKeyStore($keyName);
$this->keyOfTables[] = $keyName;
}
private function addArrayOfTableKeyToKeyStore(string $keyName) : void
{
if (isset($this->arrayOfTablekeyCounters[$keyName]) === false) {
......@@ -634,8 +640,14 @@ class Parser extends AbstractParser
$this->workArray[$keyName][] = [];
}
end($this->workArray[$keyName]);
$this->workArray = &$this->workArray[$keyName][key($this->workArray[$keyName])];
if (in_array($keyName, $this->keyOfTables) === false) {
end($this->workArray[$keyName]);
$this->workArray = &$this->workArray[$keyName][key($this->workArray[$keyName])];
return;
}
$this->workArray = &$this->workArray[$keyName];
}
private function resetWorkArrayToResultArray() : void
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment