SaintSystems\OData\ODataRequest::flattenDictionary() checks if the method exits on $arrayValue. $arrayValue could be an array itself, which would cause a type error on method_exits in PHP 8.
Existing method
/**
* Flattens the property dictionaries into
* JSON-friendly arrays
*
* @param mixed $obj the object to flatten
*
* @return array flattened object
*/
protected function flattenDictionary($obj) {
foreach ($obj as $arrayKey => $arrayValue) {
if (method_exists($arrayValue, 'getProperties')) {
$data = $arrayValue->getProperties();
$obj[$arrayKey] = $data;
} else {
$data = $arrayValue;
}
if (is_array($data)) {
$newItem = $this->flattenDictionary($data);
$obj[$arrayKey] = $newItem;
}
}
return $obj;
}
I will open a pull request for the following change, where we check if $arrayValue is either a string or an object:
/**
* Flattens the property dictionaries into
* JSON-friendly arrays
*
* @param mixed $obj the object to flatten
*
* @return array flattened object
*/
protected function flattenDictionary($obj) {
foreach ($obj as $arrayKey => $arrayValue) {
if ((is_string($arrayValue) || is_object($arrayValue)) && method_exists($arrayValue, 'getProperties')) {
$data = $arrayValue->getProperties();
$obj[$arrayKey] = $data;
} else {
$data = $arrayValue;
}
if (is_array($data)) {
$newItem = $this->flattenDictionary($data);
$obj[$arrayKey] = $newItem;
}
}
return $obj;
}
SaintSystems\OData\ODataRequest::flattenDictionary() checks if the method exits on $arrayValue. $arrayValue could be an array itself, which would cause a type error on method_exits in PHP 8.
Existing method
I will open a pull request for the following change, where we check if $arrayValue is either a string or an object: