On Tue, Jun 9, 2020 at 2:07 PM Lynn <kja...@gmail.com> wrote:

>
>
> On Tue, Jun 9, 2020 at 1:55 PM Benjamin Eberlei <kont...@beberlei.de>
> wrote:
>
>> Larry's suggestion about #[Attr] makes an important argument about
>> allowing
>> to declare attributes in code in PHP 7 in a forward compatible way that
>> has
>> not been brought up before.
>>
>> /** @ORM\Entity */
>> #[ORM\Entity]
>> class User {}
>>
>> This code would work on PHP 7 and 8.
>>
>> The #[] syntax would have about equally low breaking potential as @@. It
>> would be the same syntax as Rusts, and close to C++/C# syntax.
>>
>
> Hi,
>
> The idea of making annotations forward compatible in php7 this way has a
> big + from me. I honestly don't mind the syntax too much. How would
> multiline notations work with this?
>
> #[ORM\Entity(
>     arg1,
>     arg2
> )]
>
> This notation would obviously break in php7. Would it be possible (in this
> case) to do something like the following example? This would have php7 not
> care because they are comments, while php8 could filter the # out and make
> it a valid annotation.
>

Good point. The forward compatible syntax would need to require single line
declarations as you suggested, because the multiline syntax as you rightly
show is not valid php7.

The alternative would be requiring each attribute line to begin with #,
which I don't particularly care for and would probably be a mistake.


> #[ORM\Entity(
> #   arg1,
> #   arg2
> #)]
>
> I'm also okay with having everything on a single line, just wanted to
> point out this might cause issues.
>
> Regards,
> Lynn
>
>

Reply via email to