Possible BC break in nested array annotations with @NestedAnnotation

Author: TomasVotrubaCreated Jul 9, 2021Updated Jul 10, 2021

Hi everyone!

Thanks for adding #402 , it's a life saver with PHP 8 and migration to attributes :clap:

I've been exploring one weird bug we had in our code base:

php
/**
 * @MainAnnotation(
 *     @NestedAnnotation('one'),
 *     @NestedAnnotation('two'),
 * )
 */

What is the problem?

This code returns 1 or 2 NestedAnnotation annitatons, depending if @NamedArgumentConstructor is used above NestedAnnotation.


It should fixed in userland like this:

diff
 /**
- * @MainAnnotation(
+ * @MainAnnotation({
  *     @NestedAnnotation('one'),
  *     @NestedAnnotation('two'),
- * )
+ * })
 */

But at the moment it's a BC break, only first annotation is included. I think this BC breaks should not happen and there should be always 2 instances of NestedAnnotation regardless use of @NamedArgumentConstructor.

I'm looking into it :slightly_smiling_face: Any feedback appreciated :+1: