Skip to content

Change Attributes Syntax from @@Attr to @{Attr} #6012

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

Closed
wants to merge 3 commits into from

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