Skip to content

Instantly share code, notes, and snippets.

@Seldaek
Created August 10, 2020 11:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Seldaek/b7a3bd28920c6cc181e67a829b13a81c to your computer and use it in GitHub Desktop.
Save Seldaek/b7a3bd28920c6cc181e67a829b13a81c to your computer and use it in GitHub Desktop.
Attribute Syntax Comparisons
<?php
class FooCurrent {
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* Some sensible description
*
* @Assert\Length(max=255)
* @Assert\NotBlank()
* @ORM\Column(type="string", nullable=true)
* @Groups({"public", "address"})
*/
private $email;
}
class FooAtAt {
@@ORM\Id
@@ORM\GeneratedValue
@@ORM\Column(type="integer")
private $id;
/**
* Some sensible description
*/
@@Assert\Length(max=255)
@@Assert\NotBlank()
@@ORM\Column(type="string", nullable=true)
@@Groups({"public", "address"})
private $email;
}
class FooHashBrackets {
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type="integer")]
private $id;
/**
* Some sensible description
*/
#[Assert\Length(max=255)]
#[Assert\NotBlank()]
#[ORM\Column(type="string", nullable=true)]
#[Groups({"public", "address"})]
private $email;
}
class FooHashBracketsGrouped {
#[
ORM\Id,
ORM\GeneratedValue,
ORM\Column(type="integer")
]
private $id;
/**
* Some sensible description
*/
#[
Assert\Length(max=255),
Assert\NotBlank(),
ORM\Column(type="string", nullable=true),
Groups({"public", "address"})
]
private $email;
}
class FooAtBrackets {
@[ORM\Id]
@[ORM\GeneratedValue]
@[ORM\Column(type="integer")]
private $id;
/**
* Some sensible description
*/
@[Assert\Length(max=255)]
@[Assert\NotBlank()]
@[ORM\Column(type="string", nullable=true)]
@[Groups({"public", "address"})]
private $email;
}
class FooAtBracketsGrouped {
@[
ORM\Id,
ORM\GeneratedValue,
ORM\Column(type="integer")
]
private $id;
/**
* Some sensible description
*/
@[
Assert\Length(max=255),
Assert\NotBlank(),
ORM\Column(type="string", nullable=true),
Groups({"public", "address"})
]
private $email;
}
class FooShifts {
<<ORM\Id>>
<<ORM\GeneratedValue>>
<<ORM\Column(type="integer")>>
private $id;
/**
* Some sensible description
*/
<<Assert\Length(max=255)>>
<<Assert\NotBlank()>>
<<ORM\Column(type="string", nullable=true)>>
<<Groups({"public", "address"})>>
private $email;
}
class FooShiftsGrouped {
<<
ORM\Id,
ORM\GeneratedValue,
ORM\Column(type="integer")
>>
private $id;
/**
* Some sensible description
*/
<<
Assert\Length(max=255),
Assert\NotBlank(),
ORM\Column(type="string", nullable=true),
Groups({"public", "address"})
>>
private $email;
}
@hopeseekr
Copy link

It looks like @@Attribute is the only rational decision, so the PHP internals will go with something else, of course.

None of them write actual PHP or manage PHP teams for a living.

@ramsey
Copy link

ramsey commented Aug 14, 2020

@@Attribute is the only rational decision

Based on what rationale?

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