Skip to content

Commit 0baab9c

Browse files
committed
Fix bug where final array element did not have a comma.
1 parent ef33ef1 commit 0baab9c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ A small library to parse text representations of a PHP array and return an actua
33

44
## Installation
55

6-
Run `composer install` to run this script (and tests) in a standalone way. Alternatively, this can be used as a dependency in another project by running `composer require battye/php-array-parser:1.0.2`.
6+
Run `composer install` to run this script (and tests) in a standalone way. Alternatively, this can be used as a dependency in another project by running `composer require battye/php-array-parser:1.0.3`.
77

88
If you notice any bugs, please feel free to raise an issue or pull request.
99

src/parser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ public function parse_array($square = false)
182182
$this->tokens->force_match(")");
183183
}
184184

185-
if ($this->tokens->does_match(","))
185+
// If we are done, just break immediately
186+
if ($this->tokens->done())
186187
{
187-
$this->tokens->force_match(",");
188+
break;
188189
}
189190

190191
if ($this->tokens->does_match(";"))

0 commit comments

Comments
 (0)