diff --git a/README.md b/README.md index 1362715..38627a2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,6 @@ Supports commit: f68d014bfd4a84a64fb5f6a7c1a83a4162415d4b TODO ---- -- Support terminating commas before the closing bracket in arrays - Throw exception on extra chars after keygroup definition - Throw exception on mixed data type arrays - Throw exception on key or keygroup overwriting diff --git a/src/toml.php b/src/toml.php index 24bd065..cf45561 100755 --- a/src/toml.php +++ b/src/toml.php @@ -307,7 +307,11 @@ class Toml if($openBrackets == 0) { - $result[] = self::parseValue( trim($buffer) ); + // Allow terminating commas before the closing bracket + if(trim($buffer) != '') + { + $result[] = self::parseValue( trim($buffer) ); + } // Skip first and las brackets. We're finish. return $result; diff --git a/tests/extended.toml b/tests/extended.toml index 772546a..5ce42e6 100755 --- a/tests/extended.toml +++ b/tests/extended.toml @@ -11,7 +11,7 @@ dob = 1979-05-27T07:32:00Z # First class dates? Why not? [database] server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] +ports = [ 8001, 8001, 8002, ] connection_max = 5000 enabled = true @@ -38,11 +38,11 @@ key = [ ], [ "10.0.0.1", "Escaped \" quote" - ] + ], ] # Line breaks are OK when inside arrays hosts = [ "alpha # Try this hash", # Comment here, after string hash. - "omega" + "omega", ]