Skip to content

Commit a2edfa7

Browse files
authored
Merge pull request #68 from Nacoma/master
Prevent invalid array access _ thanks @Nacoma
2 parents e4b577a + 838f93e commit a2edfa7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/Shippo/Util.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ public static function isList($array)
1212
{
1313
if (!is_array($array))
1414
return false;
15-
15+
1616
// TODO: generally incorrect, but it's correct given Shippo's response
1717
foreach (array_keys($array) as $k) {
1818
if (!is_numeric($k))
1919
return false;
2020
}
2121
return true;
2222
}
23-
23+
2424
/**
2525
* Recursively converts the PHP Shippo object to an array.
2626
*
@@ -32,7 +32,7 @@ public static function convertShippoObjectToArray($values)
3232
$results = array();
3333
foreach ($values as $k => $v) {
3434
// FIXME: this is an encapsulation violation
35-
if ($k[0] == '_') {
35+
if (is_string($k) && $k[0] == '_') {
3636
continue;
3737
}
3838
if ($v instanceof Shippo_Object) {
@@ -45,7 +45,7 @@ public static function convertShippoObjectToArray($values)
4545
}
4646
return $results;
4747
}
48-
48+
4949
/**
5050
* Converts a response from the Shippo API to the corresponding PHP object.
5151
*

0 commit comments

Comments
 (0)