From 5bf39f1a255b7e9a923865ba5d8d4c060674492e Mon Sep 17 00:00:00 2001 From: Jason Judge Date: Tue, 30 Aug 2016 13:26:33 +0100 Subject: [PATCH] Fix PHP 5.3 compatibility issue. --- src/Message/AbstractRequest.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index 67026cb..62b6d31 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -170,16 +170,23 @@ abstract class AbstractRequest extends OmnipayAbstractRequest */ protected function filterHashFields($data) { - $hash_data = array_filter($data, function($key) { - // If the key is an array element then normalise it, e.g. pr[1] => px[x] + foreach($data as $key => $value) { + // If the key is an array element then normalise it, e.g. pr[1] => pr[x] if (strpos($key, '[')) { - $key = preg_replace('/\[[0-9]*\]/', '[x]', $key); + $normalised_key = preg_replace('/\[[0-9]*\]/', '[x]', $key); + } else { + $normalised_key = $key; } - return in_array($key, $this->hash_fields); - }, ARRAY_FILTER_USE_KEY); + // If the normalised key is not in the list of hashable keys, + // then remove that element from the supplied data. + if (! in_array($normalised_key, $this->hash_fields)) { + unset($data[$key]); + } + } - return $hash_data; + // Return the data array with non-hashable elements removed. + return $data; } /**