Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser does not distinguish between annotated arrays and repeated annotations #64

Open
rwilczek opened this issue Feb 20, 2017 · 2 comments

Comments

@rwilczek
Copy link

The current version of the annotation-parser does not tell between a single JSON-array and multiple simple annotations. But it should!

$parser = new \Minime\Annotations\Parser;
$this->assertNotSame(
    $parser->parse('@foo 1 @foo 2 @foo 3'),
    $parser->parse('@foo [1, 2, 3]')
); // FAIL. Parser errorneously gives the same result for both strings

$this->assertSame(
    ['foo' => [1, 2, 3]],
    $parser->parse('@foo 1 @foo 2 @foo 3') 
); // PASS. Parser works correctly on this

$this->assertSame(
    ['foo' => [[1, 2, 3]]],
    $parser->parse('@foo [1, 2, 3]') 
); // FAIL. Parser fails to preserve the array annotated with @foo
@marcioAlmada marcioAlmada changed the title Parser does not handle JSON-arrays correctly Parser does not distinguish between annotated arrays and repeated annotations Apr 20, 2017
@marcioAlmada
Copy link
Owner

marcioAlmada commented Apr 20, 2017

Hi!

That was actually intentional from the very beginning to consider, by default, that repeated annotations form an array of values and arrays are merged if identified with the same identifier.

It's totally possible to introduce a new Parser featuring the distinction, or even add an optional parameter into the existing default parser.

Pull requests are welcome!

@marcioAlmada
Copy link
Owner

marcioAlmada commented Apr 20, 2017

On v4 this could be adopted as a default behavior. I agree that it would be more intuitive and less ambiguous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants