Skip to content

Conversation

@gharlan
Copy link
Contributor

@gharlan gharlan commented Aug 18, 2020

I propose @{Attr} for the attributes syntax.

Pro:

  • no bc breaks
  • end delimiter
  • some similarity to docblock annotations (same es @@, @: and @[])
  • looks less like an array (compared to @[Attr] and #[Attr])
  • for me it fits well to the grouped use syntax (use App\{Foo, Bar, Baz as Qux}), where {} is already used for a comma separated list

Con:

  • no forward compatibility
  • not used by any other language
  • the grouped multiline variant looks a bit like a silenced block
@{
  ORM\Entity,
  ORM\Table("user")
}
class User
{
    @{ORM\Id, ORM\Column("integer"), ORM\GeneratedValue}
    private $id;
 
    @{ORM\Column("string", ORM\Column::UNIQUE)}
    @{Assert\Email(["message" => "The email '{{ value }}' is not a valid email."])}
    private $email;
}

@beberlei Is it possible to include this in https://wiki.php.net/rfc/shorter_attribute_syntax_change? Since there will be a STV anyway, I think it doesn't hurt to have one more option to choose from.

@cmb69 cmb69 added the RFC label Aug 21, 2020
@gharlan gharlan closed this Sep 3, 2020
@gharlan gharlan deleted the attribute_syntax branch September 3, 2020 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants