Skip to content

Commit

Permalink
Merge pull request #68 from Nacoma/master
Browse files Browse the repository at this point in the history
Prevent invalid array access _ thanks @Nacoma
  • Loading branch information
jfriedr authored Sep 14, 2020
2 parents e4b577a + 838f93e commit a2edfa7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Shippo/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public static function isList($array)
{
if (!is_array($array))
return false;

// TODO: generally incorrect, but it's correct given Shippo's response
foreach (array_keys($array) as $k) {
if (!is_numeric($k))
return false;
}
return true;
}

/**
* Recursively converts the PHP Shippo object to an array.
*
Expand All @@ -32,7 +32,7 @@ public static function convertShippoObjectToArray($values)
$results = array();
foreach ($values as $k => $v) {
// FIXME: this is an encapsulation violation
if ($k[0] == '_') {
if (is_string($k) && $k[0] == '_') {
continue;
}
if ($v instanceof Shippo_Object) {
Expand All @@ -45,7 +45,7 @@ public static function convertShippoObjectToArray($values)
}
return $results;
}

/**
* Converts a response from the Shippo API to the corresponding PHP object.
*
Expand Down

0 comments on commit a2edfa7

Please sign in to comment.