This commit is contained in:
Yuri Kuznetsov
2025-03-27 14:35:01 +02:00
parent 7763ddb802
commit 2e0f0fb7db
2 changed files with 16 additions and 0 deletions

View File

@@ -57,6 +57,14 @@ class VariableGetValueByKeyType extends BaseFunction
$reference =& $this->getVariables()->$name;
return $this->getByKey($reference, $key);
}
/**
* @throws Error
*/
private function getByKey(mixed &$reference, mixed $key): mixed
{
if (!is_array($reference) && !$reference instanceof stdClass) {
throw new Error("Cannot access by key of variable that is non-array and non-object.");
}

View File

@@ -58,6 +58,14 @@ class VariableSetKeyValueType extends BaseFunction
$reference =& $this->getVariables()->$name;
$this->setByKey($reference, $key, $value);
}
/**
* @throws Error
*/
private function setByKey(mixed &$reference, mixed $key, mixed $value): void
{
if (!is_array($reference) && !$reference instanceof stdClass) {
throw new Error("Cannot access by key of variable that is non-array and non-object.");
}