Merge pull request #9650 from dylangrech92/patch-1

Added exception for enumerated array (#9644)
This commit is contained in:
Daniel Hensby 2020-09-07 10:57:36 +01:00 committed by GitHub
commit 85242b1efe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -33,12 +33,18 @@ class ArrayData extends ViewableData
{
if (is_object($value)) {
$this->array = get_object_vars($value);
} elseif (ArrayLib::is_associative($value)) {
$this->array = $value;
} elseif (is_array($value) && count($value) === 0) {
$this->array = [];
} elseif (is_array($value)) {
if (ArrayLib::is_associative($value)) {
$this->array = $value;
} elseif (count($value) === 0) {
$this->array = [];
} else {
$message = 'ArrayData constructor expects an object or associative array,
enumerated array passed instead. Did you mean to use ArrayList?';
throw new InvalidArgumentException($message);
}
} else {
$message = 'Parameter to ArrayData constructor needs to be an object or associative array';
$message = 'ArrayData constructor expects an object or associative array';
throw new InvalidArgumentException($message);
}
parent::__construct();